[FIX] Update AmazonS3 file upload with error handling and sync operation (#10372)

pull/14697/head
madhavmalhotra3089 6 years ago committed by GitHub
parent 7c22f5d321
commit d26e8d9eba
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 25
      app/file-upload/server/config/AmazonS3.js

@ -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) {

Loading…
Cancel
Save