Skip to content

Commit

Permalink
[FIX] Update AmazonS3 file upload with error handling and sync operat…
Browse files Browse the repository at this point in the history
…ion (#10372)
  • Loading branch information
madhavmalhotra3089 authored Jun 19, 2020
1 parent 7c22f5d commit d26e8d9
Showing 1 changed file with 15 additions and 10 deletions.
25 changes: 15 additions & 10 deletions app/file-upload/server/config/AmazonS3.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,20 +9,25 @@ import '../../ufs/AmazonS3/server.js';

const get = function(file, req, res) {
const forceDownload = typeof req.query.download !== 'undefined';
const fileUrl = this.store.getRedirectURL(file, forceDownload);

if (!fileUrl) {
return res.end();
}
this.store.getRedirectURL(file, forceDownload, (err, fileUrl) => {
if (err) {
return console.error(err);
}

const storeType = file.store.split(':').pop();
if (settings.get(`FileUpload_S3_Proxy_${ storeType }`)) {
const request = /^https:/.test(fileUrl) ? https : http;
if (!fileUrl) {
return res.end();
}

return FileUpload.proxyFile(file.name, fileUrl, forceDownload, request, req, res);
}
const storeType = file.store.split(':').pop();
if (settings.get(`FileUpload_S3_Proxy_${ storeType }`)) {
const request = /^https:/.test(fileUrl) ? https : http;

return FileUpload.proxyFile(file.name, fileUrl, forceDownload, request, req, res);
}

return FileUpload.redirectToFile(fileUrl, req, res);
return FileUpload.redirectToFile(fileUrl, req, res);
});
};

const copy = function(file, out) {
Expand Down

0 comments on commit d26e8d9

Please sign in to comment.