fix(load-attachments): Check if file field is empty
This commit is contained in:
@@ -118,7 +118,7 @@ async function createLoadAttachment( type , userId , loadId ){
|
|||||||
const postLoadingAttachment = async(req, res) => {
|
const postLoadingAttachment = async(req, res) => {
|
||||||
const loadId = req.params.id;
|
const loadId = req.params.id;
|
||||||
const attachment = await createLoadAttachment( "Loading", req.JWT.payload.sub , loadId );
|
const attachment = await createLoadAttachment( "Loading", req.JWT.payload.sub , loadId );
|
||||||
const file = req.files.attachment;
|
const file = req.files?.attachment;
|
||||||
if( attachment && file ){
|
if( attachment && file ){
|
||||||
await uploadFile( s3Bucket, s3BucketKey, attachment._id, file );
|
await uploadFile( s3Bucket, s3BucketKey, attachment._id, file );
|
||||||
res.send( attachment );
|
res.send( attachment );
|
||||||
@@ -132,7 +132,7 @@ const postLoadingAttachment = async(req, res) => {
|
|||||||
const postDownloadingAttachment = async(req, res) => {
|
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 && file ){
|
if( attachment && file ){
|
||||||
await uploadFile( s3Bucket, s3BucketKey, attachment._id, file );
|
await uploadFile( s3Bucket, s3BucketKey, attachment._id, file );
|
||||||
res.send( attachment );
|
res.send( attachment );
|
||||||
|
|||||||
Reference in New Issue
Block a user