fix(S3): On S3 error report to the log and send error msg to client

This commit is contained in:
Josepablo C
2024-03-27 22:20:54 -06:00
parent 0c14e22551
commit 9e7f38392b

View File

@@ -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 };