* listParts - List parts of an open multipart upload * @param {AuthInfo} authInfo - Instance of AuthInfo class with requester's info * @param {object} request - http request object * @param {object} log - Werelogs logger * @param {function} callback - callback to server * @return {undefined}
(authInfo, request, log, callback)
| 73 | * @return {undefined} |
| 74 | */ |
| 75 | function listParts(authInfo, request, log, callback) { |
| 76 | log.debug('processing request', { method: 'listParts' }); |
| 77 | |
| 78 | const bucketName = request.bucketName; |
| 79 | const objectKey = request.objectKey; |
| 80 | const uploadId = request.query.uploadId; |
| 81 | const encoding = request.query['encoding-type']; |
| 82 | let maxParts = Number.parseInt(request.query['max-parts'], 10) ? |
| 83 | Number.parseInt(request.query['max-parts'], 10) : 1000; |
| 84 | if (maxParts < 0) { |
| 85 | monitoring.promMetrics('GET', bucketName, 400, |
| 86 | 'listMultipartUploadParts'); |
| 87 | return callback(errors.InvalidArgument); |
| 88 | } |
| 89 | if (maxParts > constants.listingHardLimit) { |
| 90 | maxParts = constants.listingHardLimit; |
| 91 | } |
| 92 | const partNumberMarker = |
| 93 | Number.parseInt(request.query['part-number-marker'], 10) ? |
| 94 | Number.parseInt(request.query['part-number-marker'], 10) : 0; |
| 95 | const metadataValMPUparams = { |
| 96 | authInfo, |
| 97 | bucketName, |
| 98 | objectKey, |
| 99 | uploadId, |
| 100 | preciseRequestType: request.apiMethods || 'listParts', |
| 101 | request, |
| 102 | }; |
| 103 | // For validating the request at the destinationBucket level |
| 104 | // params are the same as validating at the MPU level |
| 105 | // but the requestType is the more general 'objectPut' |
| 106 | // (on the theory that if you are listing the parts of |
| 107 | // an MPU being put you should have the right to put |
| 108 | // the object as a prerequisite) |
| 109 | const metadataValParams = Object.assign({}, metadataValMPUparams); |
| 110 | metadataValParams.requestType = 'objectPut'; |
| 111 | |
| 112 | let splitter = constants.splitter; |
| 113 | const responseHeaders = {}; |
| 114 | |
| 115 | async.waterfall([ |
| 116 | function checkDestBucketVal(next) { |
| 117 | standardMetadataValidateBucketAndObj(metadataValParams, request.actionImplicitDenies, log, |
| 118 | (err, destinationBucket) => { |
| 119 | if (err) { |
| 120 | return next(err, destinationBucket, null); |
| 121 | } |
| 122 | if (destinationBucket.policies) { |
| 123 | // TODO: Check bucket policies to see if user is granted |
| 124 | // permission or forbidden permission to take |
| 125 | // given action. |
| 126 | // If permitted, add 'bucketPolicyGoAhead' |
| 127 | // attribute to params for validating at MPU level. |
| 128 | // This is GH Issue#76 |
| 129 | metadataValMPUparams.requestType = |
| 130 | 'bucketPolicyGoAhead'; |
| 131 | } |
| 132 | return next(null, destinationBucket); |
no test coverage detected