fix(load-attachments): Check if file field is empty

This commit is contained in:
Josepablo C
2025-09-11 23:47:32 -06:00
parent 4fd6b0679d
commit 6f0df3cbb5

View File

@@ -118,7 +118,7 @@ async function createLoadAttachment( type , userId , loadId ){
const postLoadingAttachment = async(req, res) => {
const loadId = req.params.id;
const attachment = await createLoadAttachment( "Loading", req.JWT.payload.sub , loadId );
const file = req.files.attachment;
const file = req.files?.attachment;
if( attachment && file ){
await uploadFile( s3Bucket, s3BucketKey, attachment._id, file );
res.send( attachment );
@@ -132,7 +132,7 @@ const postLoadingAttachment = async(req, res) => {
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;
const file = req.files?.attachment;
if( attachment && file ){
await uploadFile( s3Bucket, s3BucketKey, attachment._id, file );
res.send( attachment );