* multipartDelete - DELETE an open multipart upload from a bucket * @param {AuthInfo} authInfo -Instance of AuthInfo class with requester's info * @param {object} request - request object given by router, * includes normalized headers * @param {object} log - the log
(authInfo, request, log, callback)
| 16 | * with err, result and responseMetaHeaders as arguments |
| 17 | */ |
| 18 | function multipartDelete(authInfo, request, log, callback) { |
| 19 | log.debug('processing request', { method: 'multipartDelete' }); |
| 20 | |
| 21 | const bucketName = request.bucketName; |
| 22 | const objectKey = request.objectKey; |
| 23 | const uploadId = request.query.uploadId; |
| 24 | |
| 25 | abortMultipartUpload(authInfo, bucketName, objectKey, uploadId, log, |
| 26 | (err, destinationBucket, partSizeSum) => { |
| 27 | const corsHeaders = collectCorsHeaders(request.headers.origin, |
| 28 | request.method, destinationBucket); |
| 29 | const location = destinationBucket ? |
| 30 | destinationBucket.getLocationConstraint() : null; |
| 31 | if (err && !err?.is?.NoSuchUpload) { |
| 32 | return callback(err, corsHeaders); |
| 33 | } |
| 34 | if (err?.is?.NoSuchUpload && isLegacyAWSBehavior(location)) { |
| 35 | log.trace('did not find valid mpu with uploadId', { |
| 36 | method: 'multipartDelete', |
| 37 | uploadId, |
| 38 | }); |
| 39 | monitoring.promMetrics('DELETE', bucketName, 400, |
| 40 | 'abortMultipartUpload'); |
| 41 | return callback(err, corsHeaders); |
| 42 | } |
| 43 | monitoring.promMetrics('DELETE', bucketName, 400, |
| 44 | 'abortMultipartUpload'); |
| 45 | if (!err) { |
| 46 | pushMetric('abortMultipartUpload', log, { |
| 47 | authInfo, |
| 48 | canonicalID: destinationBucket.getOwner(), |
| 49 | bucket: bucketName, |
| 50 | keys: [objectKey], |
| 51 | byteLength: partSizeSum, |
| 52 | location, |
| 53 | }); |
| 54 | |
| 55 | log.addDefaultFields({ |
| 56 | bytesDeleted: partSizeSum, |
| 57 | }); |
| 58 | if (request.serverAccessLog) { |
| 59 | // eslint-disable-next-line no-param-reassign |
| 60 | request.serverAccessLog.analyticsBytesDeleted = partSizeSum; |
| 61 | } |
| 62 | } |
| 63 | return callback(null, corsHeaders); |
| 64 | }, request); |
| 65 | } |
| 66 | |
| 67 | module.exports = multipartDelete; |
no test coverage detected