* 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)
| 9 | * if location exists; otherwise, null |
| 10 | */ |
| 11 | function 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 | |
| 27 | module.exports = checkReadLocation; |
no test coverage detected