fix: validate attachment key name
This commit is contained in:
@@ -126,6 +126,8 @@ const postLoadingAttachment = async(req, res) => {
|
|||||||
if( attachment && file ){
|
if( attachment && file ){
|
||||||
const s3resp = await uploadFile( s3Bucket, s3BucketKey, file , attachment._id );
|
const s3resp = await uploadFile( s3Bucket, s3BucketKey, file , attachment._id );
|
||||||
res.send( attachment );
|
res.send( attachment );
|
||||||
|
}else if( !file ){
|
||||||
|
res.status(400).send({ error : "attachment file not found" , code: 400 });
|
||||||
}else{
|
}else{
|
||||||
res.status(401).send({error:"Unauthorized",code:401});
|
res.status(401).send({error:"Unauthorized",code:401});
|
||||||
}
|
}
|
||||||
@@ -135,9 +137,11 @@ const postDownloadingAttachment = async(req, res) => {
|
|||||||
const loadId = req.params.id;
|
const loadId = req.params.id;
|
||||||
const attachment = await createLoadAttachment( "Downloading", req.JWT.payload.sub , loadId );
|
const attachment = await createLoadAttachment( "Downloading", req.JWT.payload.sub , loadId );
|
||||||
const file = req.files.attachment;
|
const file = req.files.attachment;
|
||||||
if( attachment ){
|
if( attachment && file ){
|
||||||
const s3resp = await uploadFile( s3Bucket, s3BucketKey, file , attachment._id );
|
const s3resp = await uploadFile( s3Bucket, s3BucketKey, file , attachment._id );
|
||||||
res.send( attachment );
|
res.send( attachment );
|
||||||
|
}else if( !file ){
|
||||||
|
res.status(400).send({ error : "attachment file not found" , code: 400 });
|
||||||
}else{
|
}else{
|
||||||
res.status(401).send({error:"Unauthorized",code:401});
|
res.status(401).send({error:"Unauthorized",code:401});
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user