Skip to content

Commit

Permalink
fixup! fixup! PATCH: AR-3095 Handle failed Image Attachment pipes
Browse files Browse the repository at this point in the history
  • Loading branch information
nmagedman committed Sep 4, 2023
1 parent 665d23f commit 8553864
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions apps/meteor/app/file-upload/server/lib/FileUpload.ts
Original file line number Diff line number Diff line change
Expand Up @@ -563,11 +563,17 @@ export const FileUpload = {
res.setHeader('Content-Disposition', `${forceDownload ? 'attachment' : 'inline'}; filename="${encodeURI(fileName)}"`);

request.get(fileUrl, (fileRes) => {
res.setHeader('x-rc-debug-url', fileUrl);
res.setHeader('x-rc-debug-status', fileRes.statusCode);
for (const [header, value] of Object.entries(fileRes.headers)) {
res.setHeader(`x-rc-debug-s3-header-${header}`, value);
}

if (fileRes.statusCode !== 200) {
res.setHeader('x-rc-debug-url', fileUrl);
res.setHeader('x-rc-debug-status', fileRes.statusCode);
res.setHeader('x-rc-debug-content-type', fileRes.headers['content-type'] || "");
res.setHeader('x-rc-debug-content-length', fileRes.headers['content-length'] || "");
// res.setHeader('x-rc-debug-url', fileUrl);
// res.setHeader('x-rc-debug-status', fileRes.statusCode);
// res.setHeader('x-rc-debug-content-type', fileRes.headers['content-type'] || "");
// res.setHeader('x-rc-debug-content-length', fileRes.headers['content-length'] || "");
res.setHeader('content-length', 0);
res.writeHead(500);
res.end();
Expand Down

0 comments on commit 8553864

Please sign in to comment.