* PUT Part Copy during a multipart upload. * @param {AuthInfo} authInfo - Instance of AuthInfo class with * requester's info * @param {request} request - request object given by router, * includes normalized headers * @param {string} sourceBucket - name of source buck
(authInfo, request, sourceBucket,
sourceObject, reqVersionId, log, callback)
| 36 | * @return {undefined} |
| 37 | */ |
| 38 | function objectPutCopyPart(authInfo, request, sourceBucket, |
| 39 | sourceObject, reqVersionId, log, callback) { |
| 40 | log.debug('processing request', { method: 'objectPutCopyPart' }); |
| 41 | const destBucketName = request.bucketName; |
| 42 | const destObjectKey = request.objectKey; |
| 43 | const mpuBucketName = `${constants.mpuBucketPrefix}${destBucketName}`; |
| 44 | const valGetParams = { |
| 45 | authInfo, |
| 46 | bucketName: sourceBucket, |
| 47 | objectKey: sourceObject, |
| 48 | versionId: reqVersionId, |
| 49 | getDeleteMarker: true, |
| 50 | requestType: 'objectGet', |
| 51 | /** |
| 52 | * Authorization will first check the target object, with an objectPut |
| 53 | * action. But in this context, the source object metadata is still |
| 54 | * unknown. In the context of quotas, to know the number of bytes that |
| 55 | * are being written, we explicitly enable the quota evaluation logic |
| 56 | * during the objectGet action instead. |
| 57 | */ |
| 58 | checkQuota: true, |
| 59 | request, |
| 60 | }; |
| 61 | |
| 62 | const partNumber = Number.parseInt(request.query.partNumber, 10); |
| 63 | // AWS caps partNumbers at 10,000 |
| 64 | if (partNumber > 10000 || !Number.isInteger(partNumber) || partNumber < 1) { |
| 65 | monitoring.promMetrics('PUT', destBucketName, 400, |
| 66 | 'putObjectCopyPart'); |
| 67 | return callback(errors.InvalidArgument); |
| 68 | } |
| 69 | // We pad the partNumbers so that the parts will be sorted |
| 70 | // in numerical order |
| 71 | const paddedPartNumber = `000000${partNumber}`.substr(-5); |
| 72 | // Note that keys in the query object retain their case, so |
| 73 | // request.query.uploadId must be called with that exact |
| 74 | // capitalization |
| 75 | const { query: { uploadId } } = request; |
| 76 | |
| 77 | const valPutParams = { |
| 78 | authInfo, |
| 79 | bucketName: destBucketName, |
| 80 | objectKey: destObjectKey, |
| 81 | requestType: 'objectPutPart', |
| 82 | checkQuota: false, |
| 83 | request, |
| 84 | }; |
| 85 | |
| 86 | // For validating the request at the MPU, the params are the same |
| 87 | // as validating for the destination bucket except additionally need |
| 88 | // the uploadId and splitter. |
| 89 | // Also, requestType is 'putPart or complete' |
| 90 | const valMPUParams = Object.assign({ |
| 91 | uploadId, |
| 92 | splitter: constants.splitter, |
| 93 | }, valPutParams); |
| 94 | valMPUParams.requestType = 'putPart or complete'; |
| 95 |
no test coverage detected