From 196f566436f1816cb2d4dff41458372a87b8bd95 Mon Sep 17 00:00:00 2001 From: Emil Eriksson <8700261+ginger51011@users.noreply.github.com> Date: Wed, 17 Aug 2022 15:44:47 +0200 Subject: [PATCH] Update file.routes.ts Fix error code --- src/routes/file.routes.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/routes/file.routes.ts b/src/routes/file.routes.ts index 64222fca..51465743 100644 --- a/src/routes/file.routes.ts +++ b/src/routes/file.routes.ts @@ -56,7 +56,7 @@ filesRoute.post('/upload', upload(), verifyAuthenticated, async (req, res) => { // Check file size (file.size is in bytes) const maxSize = config.FILES.MAX_FILE_UPLOAD_SIZE_BYTES; if (file.size > maxSize) { - return res.status(400).send(`File too big, max is ${maxSize / BYTES_PER_MB} MB`); + return res.status(413).send(`File too big, max is ${maxSize / BYTES_PER_MB} MB`); } const accessType = body?.accessType ?? AccessType.Public; @@ -81,7 +81,7 @@ filesRoute.post('/upload/avatar', upload(), verifyAuthenticated, async (req, res const maxSize = config.FILES.MAX_FILE_UPLOAD_SIZE_BYTES; const sizeConstraint = Math.min(maxAvatarSize, maxSize); if (file.size > sizeConstraint) { - return res.status(400).send(`Avatar too big, max is ${sizeConstraint / BYTES_PER_MB} MB`); + return res.status(413).send(`Avatar too big, max is ${sizeConstraint / BYTES_PER_MB} MB`); } const { user } = res.locals;