fix: validate attachment key name

This commit is contained in:
2023-10-07 16:30:39 -06:00
parent 964a94eec8
commit 54387add66

View File

@@ -126,6 +126,8 @@ const postLoadingAttachment = async(req, res) => {
if( attachment && file ){
const s3resp = await uploadFile( s3Bucket, s3BucketKey, file , attachment._id );
res.send( attachment );
}else if( !file ){
res.status(400).send({ error : "attachment file not found" , code: 400 });
}else{
res.status(401).send({error:"Unauthorized",code:401});
}
@@ -135,9 +137,11 @@ const postDownloadingAttachment = async(req, res) => {
const loadId = req.params.id;
const attachment = await createLoadAttachment( "Downloading", req.JWT.payload.sub , loadId );
const file = req.files.attachment;
if( attachment ){
if( attachment && file ){
const s3resp = await uploadFile( s3Bucket, s3BucketKey, file , attachment._id );
res.send( attachment );
}else if( !file ){
res.status(400).send({ error : "attachment file not found" , code: 400 });
}else{
res.status(401).send({error:"Unauthorized",code:401});
}