diff --git a/src/apps/public/public-load-attachments/services.js b/src/apps/public/public-load-attachments/services.js index e67f7c8..761ad3b 100644 --- a/src/apps/public/public-load-attachments/services.js +++ b/src/apps/public/public-load-attachments/services.js @@ -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 };