Skip to content

Commit

Permalink
Add zero-length audio check to backend
Browse files Browse the repository at this point in the history
  • Loading branch information
nkalupahana committed Jul 4, 2024
1 parent 6a9a5e6 commit 87553fa
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions backend/src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -276,6 +276,11 @@ export const moodLog = async (req: UserRequest, res: Response) => {
return;
}

if (audio.size === 0) {
res.status(400).send("Your audio journal has no data. Please try submitting/recording again. If you continue to see this message, your device/browser may not support audio recording.");
return;
}

const storagePath = "tmp/" + audio.newFilename;
promises.push(getStorage().bucket().file(storagePath).save(fs.readFileSync(audio.filepath), { contentType: audio.mimetype ?? undefined }).then(() => {
// Clean up temp file
Expand Down

0 comments on commit 87553fa

Please sign in to comment.