fix(S3): On S3 error report to the log and send error msg to client
This commit is contained in:
@@ -7,11 +7,16 @@ const s3Bucket = apiConfig.S3.bucket;
|
||||
const s3BucketKey = apiConfig.S3.load_attachments_key;
|
||||
|
||||
const getAttachmentFile = async(req, res) => {
|
||||
const attachmentId = req.params.id;
|
||||
const file = await downloadFile( s3Bucket, s3BucketKey, attachmentId );
|
||||
res.attachment( attachmentId );
|
||||
res.setHeader('Content-Type', file.ContentType );
|
||||
res.send( file.Body );
|
||||
try{
|
||||
const attachmentId = req.params.id;
|
||||
const file = await downloadFile( s3Bucket, s3BucketKey, attachmentId );
|
||||
res.attachment( attachmentId );
|
||||
res.setHeader('Content-Type', file.ContentType );
|
||||
res.send( file.Body );
|
||||
}catch( error ){
|
||||
console.error( error );
|
||||
res.status(500).send({ error });
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = { getAttachmentFile };
|
||||
|
||||
Reference in New Issue
Block a user