{"action":"created","comment":{"url":"https://api.github.com/repos/fog/fog-google/pulls/comments/47031146","id":47031146,"diff_hunk":"@@ -0,0 +1,95 @@\n+module Fog\n+  module Google\n+    class StorageJSON\n+      class Real\n+        # Create an object in an Google Storage bucket\n+        #\n+        # ==== Parameters\n+        # * bucket_name<~String> - Name of bucket to create object in\n+        # * object_name<~String> - Name of object to create\n+        # * data<~File> - File or String to create object from\n+        # * options<~Hash>:\n+        #   * 'Cache-Control'<~String> - Caching behaviour\n+        #   * 'Content-Disposition'<~String> - Presentational information for the object\n+        #   * 'Content-Encoding'<~String> - Encoding of object data\n+        #   * 'Content-Length'<~String> - Size of object in bytes (defaults to object.read.length)\n+        #   * 'Content-MD5'<~String> - Base64 encoded 128-bit MD5 digest of message (defaults to Base64 encoded MD5 of object.read)\n+        #   * 'Content-Type'<~String> - Standard MIME type describing contents (defaults to MIME::Types.of.first)\n+        #   * 'x-goog-acl'<~String> - Permissions, must be in ['private', 'public-read', 'public-read-write', 'authenticated-read']\n+        #   * \"x-goog-meta-#{name}\" - Headers to be returned with object, note total size of request without body must be less than 8 KB.\n+        #\n+        # ==== Returns\n+        # * response<~Excon::Response>:\n+        #   * headers<~Hash>:\n+        #     * 'ETag'<~String> - etag of new object\n+        def put_object(bucket_name, object_name, data, options = {})\n+          if data.is_a? String\n+            data = StringIO.new(data)\n+            mime_type = 'text/plain'\n+          elsif data.is_a? File\n+            mime_type = Fog::Storage.parse_data(data)[:headers]['Content-Type']\n+          end\n+\n+          media = ::Google::APIClient::UploadIO.new(data, mime_type, object_name)\n+          api_method = @storage_json.objects.insert\n+          parameters = {\n+            \"uploadType\" => \"resumable\",\n+            \"bucket\" => bucket_name,\n+            \"name\" => object_name\n+          }\n+          body_object = { \n+            contentType: mime_type\n+          }\n+\n+          request(api_method, parameters, body_object=body_object, media=media)\n+        end\n+      end\n+\n+      class Mock\n+        def put_object(bucket_name, object_name, data, options = {})\n+          acl = options[\"x-goog-acl\"] || \"private\"\n+          if ![\"private\", \"publicRead\", \"publicReadWrite\", \"authenticatedRead\"].include?(acl)\n+            raise Excon::Errors::BadRequest.new(\"invalid x-goog-acl\")\n+          else\n+            self.data[:acls][:object][bucket_name] ||= {}\n+            self.data[:acls][:object][bucket_name][object_name] = self.class.acls(acl)\n+          end\n+\n+          data = Fog::Storage.parse_data(data)\n+          data[:body] = data[:body].read unless data[:body].is_a?(String)\n+          response = Excon::Response.new\n+          if (bucket = self.data[:buckets][bucket_name])\n+            response.status = 200\n+            object = {\n+              :body             => data[:body],\n+              \"Content-Type\"    => options[\"Content-Type\"] || data[:headers][\"Content-Type\"],\n+              \"ETag\"            => Fog::Google::Mock.etag,\n+              \"Key\"             => object_name,\n+              \"Last-Modified\"   => Fog::Time.now.to_date_header,\n+              \"Content-Length\"  => options[\"Content-Length\"] || data[:headers][\"Content-Length\"]\n+            }\n+\n+            for key, value in options","path":"lib/fog/google/requests/storage_json/put_object.rb","position":72,"original_position":72,"commit_id":"88bba45624a10775666e4a2a6f71c3566a60a741","original_commit_id":"88bba45624a10775666e4a2a6f71c3566a60a741","user":{"login":"houndci","id":6697940,"avatar_url":"https://avatars.githubusercontent.com/u/6697940?v=3","gravatar_id":"","url":"https://api.github.com/users/houndci","html_url":"https://github.com/houndci","followers_url":"https://api.github.com/users/houndci/followers","following_url":"https://api.github.com/users/houndci/following{/other_user}","gists_url":"https://api.github.com/users/houndci/gists{/gist_id}","starred_url":"https://api.github.com/users/houndci/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/houndci/subscriptions","organizations_url":"https://api.github.com/users/houndci/orgs","repos_url":"https://api.github.com/users/houndci/repos","events_url":"https://api.github.com/users/houndci/events{/privacy}","received_events_url":"https://api.github.com/users/houndci/received_events","type":"User","site_admin":false},"body":"Prefer `each` over `for`.","created_at":"2015-12-08T23:29:08Z","updated_at":"2015-12-08T23:29:08Z","html_url":"https://github.com/fog/fog-google/pull/96#discussion_r47031146","pull_request_url":"https://api.github.com/repos/fog/fog-google/pulls/96","_links":{"self":{"href":"https://api.github.com/repos/fog/fog-google/pulls/comments/47031146"},"html":{"href":"https://github.com/fog/fog-google/pull/96#discussion_r47031146"},"pull_request":{"href":"https://api.github.com/repos/fog/fog-google/pulls/96"}}},"pull_request":{"url":"https://api.github.com/repos/fog/fog-google/pulls/96","id":52794599,"html_url":"https://github.com/fog/fog-google/pull/96","diff_url":"https://github.com/fog/fog-google/pull/96.diff","patch_url":"https://github.com/fog/fog-google/pull/96.patch","issue_url":"https://api.github.com/repos/fog/fog-google/issues/96","number":96,"state":"open","locked":false,"title":"New JSON Storage API","user":{"login":"icco","id":20201,"avatar_url":"https://avatars.githubusercontent.com/u/20201?v=3","gravatar_id":"","url":"https://api.github.com/users/icco","html_url":"https://github.com/icco","followers_url":"https://api.github.com/users/icco/followers","following_url":"https://api.github.com/users/icco/following{/other_user}","gists_url":"https://api.github.com/users/icco/gists{/gist_id}","starred_url":"https://api.github.com/users/icco/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/icco/subscriptions","organizations_url":"https://api.github.com/users/icco/orgs","repos_url":"https://api.github.com/users/icco/repos","events_url":"https://api.github.com/users/icco/events{/privacy}","received_events_url":"https://api.github.com/users/icco/received_events","type":"User","site_admin":false},"body":"This pull request is not ready at all, but creating it so we can finally make progress on #38.\r\n\r\nGoal for this before it's merged: Auth and get files with tests.\r\n\r\n/cc @deanputney, @Temikus and @plribeiro3000 for FYI. Feel free to leave comments and what not.","created_at":"2015-12-06T23:44:45Z","updated_at":"2015-12-08T23:29:08Z","closed_at":null,"merged_at":null,"merge_commit_sha":"b854a23ade865c42686f51f8b803a21409e0bb9e","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/fog/fog-google/pulls/96/commits","review_comments_url":"https://api.github.com/repos/fog/fog-google/pulls/96/comments","review_comment_url":"https://api.github.com/repos/fog/fog-google/pulls/comments{/number}","comments_url":"https://api.github.com/repos/fog/fog-google/issues/96/comments","statuses_url":"https://api.github.com/repos/fog/fog-google/statuses/88bba45624a10775666e4a2a6f71c3566a60a741","head":{"label":"icco:new_storage_api","ref":"new_storage_api","sha":"88bba45624a10775666e4a2a6f71c3566a60a741","user":{"login":"icco","id":20201,"avatar_url":"https://avatars.githubusercontent.com/u/20201?v=3","gravatar_id":"","url":"https://api.github.com/users/icco","html_url":"https://github.com/icco","followers_url":"https://api.github.com/users/icco/followers","following_url":"https://api.github.com/users/icco/following{/other_user}","gists_url":"https://api.github.com/users/icco/gists{/gist_id}","starred_url":"https://api.github.com/users/icco/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/icco/subscriptions","organizations_url":"https://api.github.com/users/icco/orgs","repos_url":"https://api.github.com/users/icco/repos","events_url":"https://api.github.com/users/icco/events{/privacy}","received_events_url":"https://api.github.com/users/icco/received_events","type":"User","site_admin":false},"repo":{"id":44850347,"name":"fog-google","full_name":"icco/fog-google","owner":{"login":"icco","id":20201,"avatar_url":"https://avatars.githubusercontent.com/u/20201?v=3","gravatar_id":"","url":"https://api.github.com/users/icco","html_url":"https://github.com/icco","followers_url":"https://api.github.com/users/icco/followers","following_url":"https://api.github.com/users/icco/following{/other_user}","gists_url":"https://api.github.com/users/icco/gists{/gist_id}","starred_url":"https://api.github.com/users/icco/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/icco/subscriptions","organizations_url":"https://api.github.com/users/icco/orgs","repos_url":"https://api.github.com/users/icco/repos","events_url":"https://api.github.com/users/icco/events{/privacy}","received_events_url":"https://api.github.com/users/icco/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/icco/fog-google","description":"Fog for Google Cloud Platform","fork":true,"url":"https://api.github.com/repos/icco/fog-google","forks_url":"https://api.github.com/repos/icco/fog-google/forks","keys_url":"https://api.github.com/repos/icco/fog-google/keys{/key_id}","collaborators_url":"https://api.github.com/repos/icco/fog-google/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/icco/fog-google/teams","hooks_url":"https://api.github.com/repos/icco/fog-google/hooks","issue_events_url":"https://api.github.com/repos/icco/fog-google/issues/events{/number}","events_url":"https://api.github.com/repos/icco/fog-google/events","assignees_url":"https://api.github.com/repos/icco/fog-google/assignees{/user}","branches_url":"https://api.github.com/repos/icco/fog-google/branches{/branch}","tags_url":"https://api.github.com/repos/icco/fog-google/tags","blobs_url":"https://api.github.com/repos/icco/fog-google/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/icco/fog-google/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/icco/fog-google/git/refs{/sha}","trees_url":"https://api.github.com/repos/icco/fog-google/git/trees{/sha}","statuses_url":"https://api.github.com/repos/icco/fog-google/statuses/{sha}","languages_url":"https://api.github.com/repos/icco/fog-google/languages","stargazers_url":"https://api.github.com/repos/icco/fog-google/stargazers","contributors_url":"https://api.github.com/repos/icco/fog-google/contributors","subscribers_url":"https://api.github.com/repos/icco/fog-google/subscribers","subscription_url":"https://api.github.com/repos/icco/fog-google/subscription","commits_url":"https://api.github.com/repos/icco/fog-google/commits{/sha}","git_commits_url":"https://api.github.com/repos/icco/fog-google/git/commits{/sha}","comments_url":"https://api.github.com/repos/icco/fog-google/comments{/number}","issue_comment_url":"https://api.github.com/repos/icco/fog-google/issues/comments{/number}","contents_url":"https://api.github.com/repos/icco/fog-google/contents/{+path}","compare_url":"https://api.github.com/repos/icco/fog-google/compare/{base}...{head}","merges_url":"https://api.github.com/repos/icco/fog-google/merges","archive_url":"https://api.github.com/repos/icco/fog-google/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/icco/fog-google/downloads","issues_url":"https://api.github.com/repos/icco/fog-google/issues{/number}","pulls_url":"https://api.github.com/repos/icco/fog-google/pulls{/number}","milestones_url":"https://api.github.com/repos/icco/fog-google/milestones{/number}","notifications_url":"https://api.github.com/repos/icco/fog-google/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/icco/fog-google/labels{/name}","releases_url":"https://api.github.com/repos/icco/fog-google/releases{/id}","created_at":"2015-10-24T03:18:41Z","updated_at":"2015-10-24T03:18:42Z","pushed_at":"2015-12-08T23:28:47Z","git_url":"git://github.com/icco/fog-google.git","ssh_url":"git@github.com:icco/fog-google.git","clone_url":"https://github.com/icco/fog-google.git","svn_url":"https://github.com/icco/fog-google","homepage":"","size":489,"stargazers_count":0,"watchers_count":0,"language":"Ruby","has_issues":false,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"fog:master","ref":"master","sha":"951846a126caa231fda8baa633c0eb5d4ced07fd","user":{"login":"fog","id":991149,"avatar_url":"https://avatars.githubusercontent.com/u/991149?v=3","gravatar_id":"","url":"https://api.github.com/users/fog","html_url":"https://github.com/fog","followers_url":"https://api.github.com/users/fog/followers","following_url":"https://api.github.com/users/fog/following{/other_user}","gists_url":"https://api.github.com/users/fog/gists{/gist_id}","starred_url":"https://api.github.com/users/fog/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/fog/subscriptions","organizations_url":"https://api.github.com/users/fog/orgs","repos_url":"https://api.github.com/users/fog/repos","events_url":"https://api.github.com/users/fog/events{/privacy}","received_events_url":"https://api.github.com/users/fog/received_events","type":"Organization","site_admin":false},"repo":{"id":29195078,"name":"fog-google","full_name":"fog/fog-google","owner":{"login":"fog","id":991149,"avatar_url":"https://avatars.githubusercontent.com/u/991149?v=3","gravatar_id":"","url":"https://api.github.com/users/fog","html_url":"https://github.com/fog","followers_url":"https://api.github.com/users/fog/followers","following_url":"https://api.github.com/users/fog/following{/other_user}","gists_url":"https://api.github.com/users/fog/gists{/gist_id}","starred_url":"https://api.github.com/users/fog/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/fog/subscriptions","organizations_url":"https://api.github.com/users/fog/orgs","repos_url":"https://api.github.com/users/fog/repos","events_url":"https://api.github.com/users/fog/events{/privacy}","received_events_url":"https://api.github.com/users/fog/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/fog/fog-google","description":"Fog for Google Cloud Platform","fork":false,"url":"https://api.github.com/repos/fog/fog-google","forks_url":"https://api.github.com/repos/fog/fog-google/forks","keys_url":"https://api.github.com/repos/fog/fog-google/keys{/key_id}","collaborators_url":"https://api.github.com/repos/fog/fog-google/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/fog/fog-google/teams","hooks_url":"https://api.github.com/repos/fog/fog-google/hooks","issue_events_url":"https://api.github.com/repos/fog/fog-google/issues/events{/number}","events_url":"https://api.github.com/repos/fog/fog-google/events","assignees_url":"https://api.github.com/repos/fog/fog-google/assignees{/user}","branches_url":"https://api.github.com/repos/fog/fog-google/branches{/branch}","tags_url":"https://api.github.com/repos/fog/fog-google/tags","blobs_url":"https://api.github.com/repos/fog/fog-google/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/fog/fog-google/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/fog/fog-google/git/refs{/sha}","trees_url":"https://api.github.com/repos/fog/fog-google/git/trees{/sha}","statuses_url":"https://api.github.com/repos/fog/fog-google/statuses/{sha}","languages_url":"https://api.github.com/repos/fog/fog-google/languages","stargazers_url":"https://api.github.com/repos/fog/fog-google/stargazers","contributors_url":"https://api.github.com/repos/fog/fog-google/contributors","subscribers_url":"https://api.github.com/repos/fog/fog-google/subscribers","subscription_url":"https://api.github.com/repos/fog/fog-google/subscription","commits_url":"https://api.github.com/repos/fog/fog-google/commits{/sha}","git_commits_url":"https://api.github.com/repos/fog/fog-google/git/commits{/sha}","comments_url":"https://api.github.com/repos/fog/fog-google/comments{/number}","issue_comment_url":"https://api.github.com/repos/fog/fog-google/issues/comments{/number}","contents_url":"https://api.github.com/repos/fog/fog-google/contents/{+path}","compare_url":"https://api.github.com/repos/fog/fog-google/compare/{base}...{head}","merges_url":"https://api.github.com/repos/fog/fog-google/merges","archive_url":"https://api.github.com/repos/fog/fog-google/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/fog/fog-google/downloads","issues_url":"https://api.github.com/repos/fog/fog-google/issues{/number}","pulls_url":"https://api.github.com/repos/fog/fog-google/pulls{/number}","milestones_url":"https://api.github.com/repos/fog/fog-google/milestones{/number}","notifications_url":"https://api.github.com/repos/fog/fog-google/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/fog/fog-google/labels{/name}","releases_url":"https://api.github.com/repos/fog/fog-google/releases{/id}","created_at":"2015-01-13T15:02:24Z","updated_at":"2015-11-12T17:16:27Z","pushed_at":"2015-12-08T23:28:47Z","git_url":"git://github.com/fog/fog-google.git","ssh_url":"git@github.com:fog/fog-google.git","clone_url":"https://github.com/fog/fog-google.git","svn_url":"https://github.com/fog/fog-google","homepage":"","size":520,"stargazers_count":9,"watchers_count":9,"language":"Ruby","has_issues":true,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":22,"mirror_url":null,"open_issues_count":27,"forks":22,"open_issues":27,"watchers":9,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/fog/fog-google/pulls/96"},"html":{"href":"https://github.com/fog/fog-google/pull/96"},"issue":{"href":"https://api.github.com/repos/fog/fog-google/issues/96"},"comments":{"href":"https://api.github.com/repos/fog/fog-google/issues/96/comments"},"review_comments":{"href":"https://api.github.com/repos/fog/fog-google/pulls/96/comments"},"review_comment":{"href":"https://api.github.com/repos/fog/fog-google/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/fog/fog-google/pulls/96/commits"},"statuses":{"href":"https://api.github.com/repos/fog/fog-google/statuses/88bba45624a10775666e4a2a6f71c3566a60a741"}}}}