* 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)
| 37 | * @return {undefined} |
| 38 | */ |
| 39 | function 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(); |
no test coverage detected