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

Function objectGet

lib/api/objectGet.js:39–364  ·  view source on GitHub ↗

* GET Object - Get an object * @param {AuthInfo} authInfo - Instance of AuthInfo class with requester's info * @param {object} request - normalized request object * @param {boolean} returnTagCount - returns the x-amz-tagging-count header * @param {object} log - Werelogs instance * @param {funct

(authInfo, request, returnTagCount, log, callback)

Source from the content-addressed store, hash-verified

37 * @return {undefined}
38 */
39function objectGet(authInfo, request, returnTagCount, log, callback) {
40 log.debug('processing request', { method: 'objectGet' });
41 const bucketName = request.bucketName;
42 const objectKey = request.objectKey;
43
44 // returns name of location to get from and key if successful
45 const locCheckResult =
46 locationHeaderCheck(request.headers, objectKey, bucketName);
47 if (locCheckResult instanceof Error) {
48 log.trace('invalid location constraint to get from', {
49 location: request.headers['x-amz-location-constraint'],
50 error: locCheckResult,
51 });
52 return callback(locCheckResult);
53 }
54
55 const decodedVidResult = decodeVersionId(request.query);
56 if (decodedVidResult instanceof Error) {
57 log.trace('invalid versionId query', {
58 versionId: request.query.versionId,
59 error: decodedVidResult,
60 });
61 return callback(decodedVidResult);
62 }
63 const versionId = decodedVidResult;
64
65 const mdValParams = {
66 authInfo,
67 bucketName,
68 objectKey,
69 versionId,
70 getDeleteMarker: true,
71 requestType: request.apiMethods || 'objectGet',
72 request,
73 returnTagCount,
74 };
75
76 return standardMetadataValidateBucketAndObj(mdValParams, request.actionImplicitDenies, log,
77 (err, bucket, objMD) => updateEncryption(err, bucket, objMD, objectKey, log, {},
78 (err, bucket, objMD) => {
79 const corsHeaders = collectCorsHeaders(request.headers.origin,
80 request.method, bucket);
81 if (err) {
82 log.debug('error processing request', {
83 error: err,
84 method: 'metadataValidateBucketAndObj',
85 });
86 monitoring.promMetrics(
87 'GET', bucketName, err.code, 'getObject');
88 return callback(err, null, corsHeaders);
89 }
90 if (!objMD) {
91 const err = versionId ? errors.NoSuchVersion : errors.NoSuchKey;
92 monitoring.promMetrics(
93 'GET', bucketName, err.code, 'getObject');
94 return callback(err, null, corsHeaders);
95 }
96 const verCfg = bucket.getVersioningConfiguration();

Callers 5

objectDelete.jsFile · 0.85
objectGet.jsFile · 0.85
transientBucket.jsFile · 0.85
assertObjOnBackendFunction · 0.85

Calls 15

locationHeaderCheckFunction · 0.85
updateEncryptionFunction · 0.85
collectCorsHeadersFunction · 0.85
getVersionIdResHeaderFunction · 0.85
validateHeadersFunction · 0.85
collectResponseHeadersFunction · 0.85
setExpirationHeadersFunction · 0.85
checkReadLocationFunction · 0.85
setPartRangesFunction · 0.85

Tested by

no test coverage detected