MCPcopy
hub / github.com/scality/cloudserver / multipartDelete

Function multipartDelete

lib/api/multipartDelete.js:18–65  ·  view source on GitHub ↗

* 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)

Source from the content-addressed store, hash-verified

16 * with err, result and responseMetaHeaders as arguments
17 */
18function 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
67module.exports = multipartDelete;

Callers 6

_createAndAbortMpuFunction · 0.85
transientBucket.jsFile · 0.85
multipartUpload.jsFile · 0.85
abortMultipleMpusFunction · 0.85
multipartUpload.jsFile · 0.85

Calls 8

collectCorsHeadersFunction · 0.85
pushMetricFunction · 0.85
debugMethod · 0.80
getLocationConstraintMethod · 0.80
traceMethod · 0.80
getOwnerMethod · 0.80
addDefaultFieldsMethod · 0.80
abortMultipartUploadFunction · 0.50

Tested by

no test coverage detected