diff --git a/src/app/api/customer/FilesController.ts b/src/app/api/customer/FilesController.ts index 67fea6e2..925b30c7 100644 --- a/src/app/api/customer/FilesController.ts +++ b/src/app/api/customer/FilesController.ts @@ -88,10 +88,6 @@ export default class FilesController extends ApiController { try { //get file if (!req.file) throw new Error("No file provided"); - if (req.file.mimetype !== "application/pdf" && req.file.mimetype !== "image/png" && req.file.mimetype !== "image/jpeg") { - this.httpBadRequest(response, "File type not supported"); - return; - } //init File resource with request body values const fileEntity = File.hydrate(JSON.parse(req.body["q"])); diff --git a/src/app/middlewares/CustomerHandler/FileHandler.ts b/src/app/middlewares/CustomerHandler/FileHandler.ts index 0c9d82a1..42a85c11 100644 --- a/src/app/middlewares/CustomerHandler/FileHandler.ts +++ b/src/app/middlewares/CustomerHandler/FileHandler.ts @@ -9,6 +9,11 @@ export default async function fileHandler(req: Request, response: Response, next const uid = req.path && req.path.split("/")[5]; const document = req.body.document; + if (req.file?.mimetype !== "application/pdf" && req.file?.mimetype !== "image/png" && req.file?.mimetype !== "image/jpeg") { + response.status(HttpCodes.BAD_REQUEST).send("File type not supported"); + return; + } + if (uid) { const fileService = Container.get(FilesService); const file = await fileService.getByUidWithDocument(uid);