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 s3BucketKey = apiConfig.S3.load_attachments_key;
|
||||||
|
|
||||||
const getAttachmentFile = async(req, res) => {
|
const getAttachmentFile = async(req, res) => {
|
||||||
const attachmentId = req.params.id;
|
try{
|
||||||
const file = await downloadFile( s3Bucket, s3BucketKey, attachmentId );
|
const attachmentId = req.params.id;
|
||||||
res.attachment( attachmentId );
|
const file = await downloadFile( s3Bucket, s3BucketKey, attachmentId );
|
||||||
res.setHeader('Content-Type', file.ContentType );
|
res.attachment( attachmentId );
|
||||||
res.send( file.Body );
|
res.setHeader('Content-Type', file.ContentType );
|
||||||
|
res.send( file.Body );
|
||||||
|
}catch( error ){
|
||||||
|
console.error( error );
|
||||||
|
res.status(500).send({ error });
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
module.exports = { getAttachmentFile };
|
module.exports = { getAttachmentFile };
|
||||||
|
|||||||
Reference in New Issue
Block a user