MCPcopy Index your code
hub / github.com/scality/cloudserver / objectPutTagging

Function objectPutTagging

lib/api/objectPutTagging.js:26–124  ·  view source on GitHub ↗

* Object Put Tagging - Adds tag(s) to object * @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)

Source from the content-addressed store, hash-verified

24 * @return {undefined}
25 */
26function objectPutTagging(authInfo, request, log, callback) {
27 log.debug('processing request', { method: 'objectPutTagging' });
28
29 const { bucketName, objectKey } = request;
30 const decodedVidResult = decodeVersionId(request.query);
31 if (decodedVidResult instanceof Error) {
32 log.trace('invalid versionId query', {
33 versionId: request.query.versionId,
34 error: decodedVidResult,
35 });
36 return process.nextTick(() => callback(decodedVidResult));
37 }
38 const reqVersionId = decodedVidResult;
39
40 const metadataValParams = {
41 authInfo,
42 bucketName,
43 objectKey,
44 versionId: reqVersionId,
45 getDeleteMarker: true,
46 requestType: request.apiMethods || 'objectPutTagging',
47 request,
48 };
49
50 return async.waterfall([
51 next => standardMetadataValidateBucketAndObj(metadataValParams, request.actionImplicitDenies, log,
52 (err, bucket, objectMD) => {
53 if (err) {
54 log.trace('request authorization failed',
55 { method: 'objectPutTagging', error: err });
56 return next(err);
57 }
58 if (!objectMD) {
59 const err = reqVersionId ? errors.NoSuchVersion :
60 errors.NoSuchKey;
61 log.trace('error no object metadata found',
62 { method: 'objectPutTagging', error: err });
63 return next(err, bucket);
64 }
65 if (objectMD.isDeleteMarker) {
66 log.trace('version is a delete marker',
67 { method: 'objectPutTagging' });
68 // FIXME we should return a `x-amz-delete-marker: true` header,
69 // see S3C-7592
70 return next(errors.MethodNotAllowed, bucket);
71 }
72 return next(null, bucket, objectMD);
73 }),
74 (bucket, objectMD, next) => {
75 log.trace('parsing tag(s)');
76 parseTagXml(request.post, log, (err, tags) =>
77 next(err, bucket, tags, objectMD));
78 },
79 (bucket, tags, objectMD, next) => {
80 // eslint-disable-next-line no-param-reassign
81 objectMD.tags = tags;
82 const params = getVersionSpecificMetadataOptions(objectMD, config.nullVersionCompatMode);
83 const replicationInfo = getReplicationInfo(config,

Callers 4

Calls 9

getReplicationInfoFunction · 0.85
collectCorsHeadersFunction · 0.85
pushMetricFunction · 0.85
getVersionIdResHeaderFunction · 0.85
debugMethod · 0.80
traceMethod · 0.80
decodeVersionIdFunction · 0.50

Tested by

no test coverage detected