Skip to content

Commit

Permalink
PATCH: AR-3095 Handle failed Image Attachment pipes (part 2)
Browse files Browse the repository at this point in the history
If S3 authentication fails, return 500
  • Loading branch information
nmagedman committed Sep 4, 2023
1 parent 8553864 commit c3fa833
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion apps/meteor/app/file-upload/server/config/AmazonS3.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,14 @@ const get: FileUploadClass['get'] = async function (this: FileUploadClass, file,
const forceDownload = typeof query.download !== 'undefined';

const fileUrl = await this.store.getRedirectURL(file, forceDownload);
if (!fileUrl || !file.store) {
if (!fileUrl || !file.store || fileUrl === 'https://s3.us-west-2.amazonaws.com/') {
// If the credentials fail, getRedirectURL can return the string above,
// which just 307s (incidentally to https://aws.amazon.com/s3/).
// Proxying that 307 (in proxyFile(), below) just sends an empty body and closes the connection,
// causing us to falsey return an empty file.
// HACK: just fail 500 and hopefully it will succeed the next time around.
res.setHeader('x-rc-debug-s3url', fileUrl || '');
res.writeHead(500);
res.end();
return;
}
Expand Down

0 comments on commit c3fa833

Please sign in to comment.