Skip to content

Commit 90af209

Browse files
committed
Use pre-signed URL for public object downloads
1 parent 47f250b commit 90af209

File tree

1 file changed

+6
-28
lines changed

1 file changed

+6
-28
lines changed

app/src/controllers/object.js

Lines changed: 6 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@ const {
2121
getCurrentIdentity,
2222
getKeyValue,
2323
getMetadata,
24-
getS3Url,
2524
getS3VersionId,
2625
joinPath,
2726
isTruthy,
@@ -882,40 +881,19 @@ const controller = {
882881
}
883882
}
884883
else {
885-
let s3Url;
886-
// if object is public, construct S3 url manually
887-
if (req.currentObject.public) {
888-
s3Url = await getS3Url(data);
889-
}
890-
// else get pre-signed S3 url
891-
else {
892-
s3Url = await storageService.readSignedUrl({
893-
expiresIn: req.query.expiresIn,
894-
...data
895-
});
896-
}
884+
// get pre-signed S3 url
885+
886+
const s3Url = await storageService.readSignedUrl({
887+
expiresIn: req.query.expiresIn,
888+
...data
889+
});
897890

898891
// if request was for a url, present download url link
899892
if (req.query.download && req.query.download === DownloadMode.URL) {
900893
res.status(201).json(s3Url);
901894
}
902895
// Download via HTTP redirect
903896
else {
904-
/**
905-
* Set CSP header to allow redirect to S3 URL
906-
* /
907-
// res
908-
// .set(
909-
// 'Content-Security-Policy', 'default-src \'self\'; ' +
910-
// 'connect-src \'self\' \'' + new URL(s3Url).origin + '\''
911-
// )
912-
// .set('Location', s3Url)
913-
// .end();
914-
915-
/**
916-
* use express redirect
917-
* note: this will be a 302 redirect which is necessary for CORS preflight to work properly
918-
*/
919897
res.redirect(s3Url);
920898
}
921899
}

0 commit comments

Comments
 (0)