{"action":"created","comment":{"url":"https://api.github.com/repos/scality/S3/pulls/comments/91352282","pull_request_review_id":11861611,"id":91352282,"diff_hunk":"@@ -1,57 +1,24 @@\n+import assert from 'assert';\n+import async from 'async';\n import { errors } from 'arsenal';\n \n-import services from '../services';\n import constants from '../../constants';\n import kms from '../kms/wrapper';\n+import { isBucketAuthorized } from './apiUtils/authorization/aclChecks';\n+import { dataStore } from './apiUtils/object/storeObject';\n+import metadata from '../metadata/wrapper';\n \n-/*\n- * Private function\n- */\n-function doStore(objectKeyContext, cipherBundle, request, log,\n-                 partNumber, size, uploadId, streamingV4Params, cb) {\n-    return function mdValidateMPU(err, mpuBucket) {\n-        if (err) {\n-            return cb(err);\n-        }\n-        return services.dataStore(\n-            null, objectKeyContext, cipherBundle, request,\n-            size, streamingV4Params, log, (err, extraArg, dataGetInfo,\n-                calculatedHash) => {\n-                if (err) {\n-                    return cb(err);\n-                }\n-                let splitter = constants.splitter;\n-                // BACKWARD: Remove to remove the old splitter\n-                if (mpuBucket.getMdBucketModelVersion() < 2) {\n-                    splitter = constants.oldSplitter;\n-                }\n-                // To be consistent with objectPutCopyPart where there could be\n-                // multiple locations, use an array here.\n-                const dataGetInfoArr = [dataGetInfo];\n-                if (cipherBundle) {\n-                    dataGetInfoArr[0].sseAlgorithm = cipherBundle.algorithm;\n-                    dataGetInfoArr[0].sseMasterKeyId = cipherBundle.masterKeyId;\n-                    dataGetInfoArr[0].sseCryptoScheme =\n-                        cipherBundle.cryptoScheme;\n-                    dataGetInfoArr[0].sseCipheredDataKey =\n-                        cipherBundle.cipheredDataKey;\n-                }\n-                const mdParams = {\n-                    partNumber,\n-                    contentMD5: calculatedHash,\n-                    size,\n-                    uploadId,\n-                    splitter,\n-                };\n-                return services.metadataStorePart(mpuBucket.getName(),\n-                    dataGetInfoArr, mdParams, log, err => {\n-                        if (err) {\n-                            return cb(err);\n-                        }\n-                        return cb(null, calculatedHash);\n-                    });\n-            });\n-    };\n+// We pad the partNumbers so that the parts will be sorted in numerical order.\n+function _getPaddedPartNumber(number) {\n+    return `000000${number}`.substr(-5);\n+}\n+\n+function _getPrefixKey(splitter, objectKey, uploadId) {","path":"lib/api/objectPutPart.js","position":65,"original_position":65,"commit_id":"a9c05e25b9a92f2126f5c12ac36dd69d77efee32","original_commit_id":"a9c05e25b9a92f2126f5c12ac36dd69d77efee32","user":{"login":"LaurenSpiegel","id":7368115,"avatar_url":"https://avatars.githubusercontent.com/u/7368115?v=3","gravatar_id":"","url":"https://api.github.com/users/LaurenSpiegel","html_url":"https://github.com/LaurenSpiegel","followers_url":"https://api.github.com/users/LaurenSpiegel/followers","following_url":"https://api.github.com/users/LaurenSpiegel/following{/other_user}","gists_url":"https://api.github.com/users/LaurenSpiegel/gists{/gist_id}","starred_url":"https://api.github.com/users/LaurenSpiegel/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/LaurenSpiegel/subscriptions","organizations_url":"https://api.github.com/users/LaurenSpiegel/orgs","repos_url":"https://api.github.com/users/LaurenSpiegel/repos","events_url":"https://api.github.com/users/LaurenSpiegel/events{/privacy}","received_events_url":"https://api.github.com/users/LaurenSpiegel/received_events","type":"User","site_admin":false},"body":"I would call this _getOverviewKey","created_at":"2016-12-07T18:12:39Z","updated_at":"2016-12-07T18:12:39Z","html_url":"https://github.com/scality/S3/pull/434#discussion_r91352282","pull_request_url":"https://api.github.com/repos/scality/S3/pulls/434","_links":{"self":{"href":"https://api.github.com/repos/scality/S3/pulls/comments/91352282"},"html":{"href":"https://github.com/scality/S3/pull/434#discussion_r91352282"},"pull_request":{"href":"https://api.github.com/repos/scality/S3/pulls/434"}}},"pull_request":{"url":"https://api.github.com/repos/scality/S3/pulls/434","id":95767416,"html_url":"https://github.com/scality/S3/pull/434","diff_url":"https://github.com/scality/S3/pull/434.diff","patch_url":"https://github.com/scality/S3/pull/434.patch","issue_url":"https://api.github.com/repos/scality/S3/issues/434","number":434,"state":"open","locked":false,"title":"FIX: Refactor objectPutPart API","user":{"login":"bennettbuchanan","id":15207067,"avatar_url":"https://avatars.githubusercontent.com/u/15207067?v=3","gravatar_id":"","url":"https://api.github.com/users/bennettbuchanan","html_url":"https://github.com/bennettbuchanan","followers_url":"https://api.github.com/users/bennettbuchanan/followers","following_url":"https://api.github.com/users/bennettbuchanan/following{/other_user}","gists_url":"https://api.github.com/users/bennettbuchanan/gists{/gist_id}","starred_url":"https://api.github.com/users/bennettbuchanan/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/bennettbuchanan/subscriptions","organizations_url":"https://api.github.com/users/bennettbuchanan/orgs","repos_url":"https://api.github.com/users/bennettbuchanan/repos","events_url":"https://api.github.com/users/bennettbuchanan/events{/privacy}","received_events_url":"https://api.github.com/users/bennettbuchanan/received_events","type":"User","site_admin":false},"body":"Fixes refactoring part of #153\r\n\r\n* Call `metadata.getBucket` directly and perform validation checks in the API.\r\n* Remove calls to `services.metadataValidateAuthorization`, `services.metadataValidateMultipart`, and `services.getMPUBucket`.\r\n* Remove `doStore` function and instead call `services.dataStore` and `services.metadataStorePart` directly in API.\r\n* Remove extraneous code after the above changes.","created_at":"2016-11-29T20:18:17Z","updated_at":"2016-12-07T18:12:39Z","closed_at":null,"merged_at":null,"merge_commit_sha":"86d0874c509a64737ea65fbdf6dccecde18f2a5f","assignee":null,"assignees":[],"milestone":null,"commits_url":"https://api.github.com/repos/scality/S3/pulls/434/commits","review_comments_url":"https://api.github.com/repos/scality/S3/pulls/434/comments","review_comment_url":"https://api.github.com/repos/scality/S3/pulls/comments{/number}","comments_url":"https://api.github.com/repos/scality/S3/issues/434/comments","statuses_url":"https://api.github.com/repos/scality/S3/statuses/a9c05e25b9a92f2126f5c12ac36dd69d77efee32","head":{"label":"scality:fix/objectPutPart","ref":"fix/objectPutPart","sha":"a9c05e25b9a92f2126f5c12ac36dd69d77efee32","user":{"login":"scality","id":383812,"avatar_url":"https://avatars.githubusercontent.com/u/383812?v=3","gravatar_id":"","url":"https://api.github.com/users/scality","html_url":"https://github.com/scality","followers_url":"https://api.github.com/users/scality/followers","following_url":"https://api.github.com/users/scality/following{/other_user}","gists_url":"https://api.github.com/users/scality/gists{/gist_id}","starred_url":"https://api.github.com/users/scality/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/scality/subscriptions","organizations_url":"https://api.github.com/users/scality/orgs","repos_url":"https://api.github.com/users/scality/repos","events_url":"https://api.github.com/users/scality/events{/privacy}","received_events_url":"https://api.github.com/users/scality/received_events","type":"Organization","site_admin":false},"repo":{"id":60165924,"name":"S3","full_name":"scality/S3","owner":{"login":"scality","id":383812,"avatar_url":"https://avatars.githubusercontent.com/u/383812?v=3","gravatar_id":"","url":"https://api.github.com/users/scality","html_url":"https://github.com/scality","followers_url":"https://api.github.com/users/scality/followers","following_url":"https://api.github.com/users/scality/following{/other_user}","gists_url":"https://api.github.com/users/scality/gists{/gist_id}","starred_url":"https://api.github.com/users/scality/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/scality/subscriptions","organizations_url":"https://api.github.com/users/scality/orgs","repos_url":"https://api.github.com/users/scality/repos","events_url":"https://api.github.com/users/scality/events{/privacy}","received_events_url":"https://api.github.com/users/scality/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/scality/S3","description":"An open-source Node.js implementation of a server handling the S3 protocol","fork":false,"url":"https://api.github.com/repos/scality/S3","forks_url":"https://api.github.com/repos/scality/S3/forks","keys_url":"https://api.github.com/repos/scality/S3/keys{/key_id}","collaborators_url":"https://api.github.com/repos/scality/S3/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/scality/S3/teams","hooks_url":"https://api.github.com/repos/scality/S3/hooks","issue_events_url":"https://api.github.com/repos/scality/S3/issues/events{/number}","events_url":"https://api.github.com/repos/scality/S3/events","assignees_url":"https://api.github.com/repos/scality/S3/assignees{/user}","branches_url":"https://api.github.com/repos/scality/S3/branches{/branch}","tags_url":"https://api.github.com/repos/scality/S3/tags","blobs_url":"https://api.github.com/repos/scality/S3/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/scality/S3/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/scality/S3/git/refs{/sha}","trees_url":"https://api.github.com/repos/scality/S3/git/trees{/sha}","statuses_url":"https://api.github.com/repos/scality/S3/statuses/{sha}","languages_url":"https://api.github.com/repos/scality/S3/languages","stargazers_url":"https://api.github.com/repos/scality/S3/stargazers","contributors_url":"https://api.github.com/repos/scality/S3/contributors","subscribers_url":"https://api.github.com/repos/scality/S3/subscribers","subscription_url":"https://api.github.com/repos/scality/S3/subscription","commits_url":"https://api.github.com/repos/scality/S3/commits{/sha}","git_commits_url":"https://api.github.com/repos/scality/S3/git/commits{/sha}","comments_url":"https://api.github.com/repos/scality/S3/comments{/number}","issue_comment_url":"https://api.github.com/repos/scality/S3/issues/comments{/number}","contents_url":"https://api.github.com/repos/scality/S3/contents/{+path}","compare_url":"https://api.github.com/repos/scality/S3/compare/{base}...{head}","merges_url":"https://api.github.com/repos/scality/S3/merges","archive_url":"https://api.github.com/repos/scality/S3/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/scality/S3/downloads","issues_url":"https://api.github.com/repos/scality/S3/issues{/number}","pulls_url":"https://api.github.com/repos/scality/S3/pulls{/number}","milestones_url":"https://api.github.com/repos/scality/S3/milestones{/number}","notifications_url":"https://api.github.com/repos/scality/S3/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/scality/S3/labels{/name}","releases_url":"https://api.github.com/repos/scality/S3/releases{/id}","deployments_url":"https://api.github.com/repos/scality/S3/deployments","created_at":"2016-06-01T09:58:56Z","updated_at":"2016-12-07T11:16:10Z","pushed_at":"2016-12-07T04:15:44Z","git_url":"git://github.com/scality/S3.git","ssh_url":"git@github.com:scality/S3.git","clone_url":"https://github.com/scality/S3.git","svn_url":"https://github.com/scality/S3","homepage":"http://s3.scality.com","size":4151,"stargazers_count":277,"watchers_count":277,"language":"JavaScript","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":38,"mirror_url":null,"open_issues_count":38,"forks":38,"open_issues":38,"watchers":277,"default_branch":"master"}},"base":{"label":"scality:master","ref":"master","sha":"3d194c359e06d3814807e9eb7f465942ab729d34","user":{"login":"scality","id":383812,"avatar_url":"https://avatars.githubusercontent.com/u/383812?v=3","gravatar_id":"","url":"https://api.github.com/users/scality","html_url":"https://github.com/scality","followers_url":"https://api.github.com/users/scality/followers","following_url":"https://api.github.com/users/scality/following{/other_user}","gists_url":"https://api.github.com/users/scality/gists{/gist_id}","starred_url":"https://api.github.com/users/scality/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/scality/subscriptions","organizations_url":"https://api.github.com/users/scality/orgs","repos_url":"https://api.github.com/users/scality/repos","events_url":"https://api.github.com/users/scality/events{/privacy}","received_events_url":"https://api.github.com/users/scality/received_events","type":"Organization","site_admin":false},"repo":{"id":60165924,"name":"S3","full_name":"scality/S3","owner":{"login":"scality","id":383812,"avatar_url":"https://avatars.githubusercontent.com/u/383812?v=3","gravatar_id":"","url":"https://api.github.com/users/scality","html_url":"https://github.com/scality","followers_url":"https://api.github.com/users/scality/followers","following_url":"https://api.github.com/users/scality/following{/other_user}","gists_url":"https://api.github.com/users/scality/gists{/gist_id}","starred_url":"https://api.github.com/users/scality/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/scality/subscriptions","organizations_url":"https://api.github.com/users/scality/orgs","repos_url":"https://api.github.com/users/scality/repos","events_url":"https://api.github.com/users/scality/events{/privacy}","received_events_url":"https://api.github.com/users/scality/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/scality/S3","description":"An open-source Node.js implementation of a server handling the S3 protocol","fork":false,"url":"https://api.github.com/repos/scality/S3","forks_url":"https://api.github.com/repos/scality/S3/forks","keys_url":"https://api.github.com/repos/scality/S3/keys{/key_id}","collaborators_url":"https://api.github.com/repos/scality/S3/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/scality/S3/teams","hooks_url":"https://api.github.com/repos/scality/S3/hooks","issue_events_url":"https://api.github.com/repos/scality/S3/issues/events{/number}","events_url":"https://api.github.com/repos/scality/S3/events","assignees_url":"https://api.github.com/repos/scality/S3/assignees{/user}","branches_url":"https://api.github.com/repos/scality/S3/branches{/branch}","tags_url":"https://api.github.com/repos/scality/S3/tags","blobs_url":"https://api.github.com/repos/scality/S3/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/scality/S3/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/scality/S3/git/refs{/sha}","trees_url":"https://api.github.com/repos/scality/S3/git/trees{/sha}","statuses_url":"https://api.github.com/repos/scality/S3/statuses/{sha}","languages_url":"https://api.github.com/repos/scality/S3/languages","stargazers_url":"https://api.github.com/repos/scality/S3/stargazers","contributors_url":"https://api.github.com/repos/scality/S3/contributors","subscribers_url":"https://api.github.com/repos/scality/S3/subscribers","subscription_url":"https://api.github.com/repos/scality/S3/subscription","commits_url":"https://api.github.com/repos/scality/S3/commits{/sha}","git_commits_url":"https://api.github.com/repos/scality/S3/git/commits{/sha}","comments_url":"https://api.github.com/repos/scality/S3/comments{/number}","issue_comment_url":"https://api.github.com/repos/scality/S3/issues/comments{/number}","contents_url":"https://api.github.com/repos/scality/S3/contents/{+path}","compare_url":"https://api.github.com/repos/scality/S3/compare/{base}...{head}","merges_url":"https://api.github.com/repos/scality/S3/merges","archive_url":"https://api.github.com/repos/scality/S3/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/scality/S3/downloads","issues_url":"https://api.github.com/repos/scality/S3/issues{/number}","pulls_url":"https://api.github.com/repos/scality/S3/pulls{/number}","milestones_url":"https://api.github.com/repos/scality/S3/milestones{/number}","notifications_url":"https://api.github.com/repos/scality/S3/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/scality/S3/labels{/name}","releases_url":"https://api.github.com/repos/scality/S3/releases{/id}","deployments_url":"https://api.github.com/repos/scality/S3/deployments","created_at":"2016-06-01T09:58:56Z","updated_at":"2016-12-07T11:16:10Z","pushed_at":"2016-12-07T04:15:44Z","git_url":"git://github.com/scality/S3.git","ssh_url":"git@github.com:scality/S3.git","clone_url":"https://github.com/scality/S3.git","svn_url":"https://github.com/scality/S3","homepage":"http://s3.scality.com","size":4151,"stargazers_count":277,"watchers_count":277,"language":"JavaScript","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":38,"mirror_url":null,"open_issues_count":38,"forks":38,"open_issues":38,"watchers":277,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/scality/S3/pulls/434"},"html":{"href":"https://github.com/scality/S3/pull/434"},"issue":{"href":"https://api.github.com/repos/scality/S3/issues/434"},"comments":{"href":"https://api.github.com/repos/scality/S3/issues/434/comments"},"review_comments":{"href":"https://api.github.com/repos/scality/S3/pulls/434/comments"},"review_comment":{"href":"https://api.github.com/repos/scality/S3/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/scality/S3/pulls/434/commits"},"statuses":{"href":"https://api.github.com/repos/scality/S3/statuses/a9c05e25b9a92f2126f5c12ac36dd69d77efee32"}}}}
{"actor":{"display_login":"LaurenSpiegel"}}