diff --git a/app/lib/actions/billActions.ts b/app/lib/actions/billActions.ts index 2ebb595..3a5de12 100644 --- a/app/lib/actions/billActions.ts +++ b/app/lib/actions/billActions.ts @@ -86,7 +86,7 @@ const serializeAttachment = async (billAttachment: File | null) => { lastModified: fileLastModified, } = billAttachment; - if(!fileName || fileName === 'undefined') { + if(!fileName || fileName === 'undefined' || fileSize === 0) { return null; } @@ -150,9 +150,7 @@ export const updateOrAddBill = withUser(async (user:AuthenticatedUser, locationI // update the bill in the mongodb const dbClient = await getDbClient(); - const billAttachmentFile = formData.get('billAttachment') as File; - const billAttachment = billAttachmentFile && billAttachmentFile.size > 0 ? - await serializeAttachment(billAttachmentFile) : null; + const billAttachment = await serializeAttachment(formData.get('billAttachment') as File); if(billId) {