Implement getRedirectUrl() for the S3 backend

This commit is contained in:
Eric Mc Sween
2020-07-08 17:13:20 -04:00
parent 7abea41166
commit 3e7e4369af
4 changed files with 39 additions and 7 deletions
+19 -3
View File
@@ -114,9 +114,25 @@ module.exports = class S3Persistor extends AbstractPersistor {
}
}
async getRedirectUrl() {
// not implemented
return null
async getRedirectUrl(bucketName, key) {
const expiresSeconds = Math.round(this.settings.signedUrlExpiryInMs / 1000)
try {
const url = await this._getClientForBucket(
bucketName
).getSignedUrlPromise('getObject', {
Bucket: bucketName,
Key: key,
Expires: expiresSeconds
})
return url
} catch (err) {
throw PersistorHelper.wrapError(
err,
'error generating signed url for S3 file',
{ bucketName, key },
ReadError
)
}
}
async deleteDirectory(bucketName, key, continuationToken) {