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

Function checkReadLocation

lib/api/apiUtils/object/checkReadLocation.js:11–25  ·  view source on GitHub ↗

* checkReadLocation - verify that a bucket's default read location exists * for a specified read data locator * @param {Config} config - Config object * @param {string} locationName - location constraint * @param {string} objectKey - object key * @param {string} bucketName - bucket name * @ret

(config, locationName, objectKey, bucketName)

Source from the content-addressed store, hash-verified

9 * if location exists; otherwise, null
10 */
11function checkReadLocation(config, locationName, objectKey, bucketName) {
12 const readLocation = config.getLocationConstraint(locationName);
13 if (readLocation) {
14 const bucketMatch = readLocation.details &&
15 readLocation.details.bucketMatch;
16 const backendKey = bucketMatch ? objectKey :
17 `${bucketName}/${objectKey}`;
18 return {
19 location: locationName,
20 key: backendKey,
21 locationType: readLocation.type,
22 };
23 }
24 return null;
25}
26
27module.exports = checkReadLocation;

Callers 2

objectGetFunction · 0.85

Calls 1

getLocationConstraintMethod · 0.80

Tested by

no test coverage detected