add mimetype check on file middleware
This commit is contained in:
parent
f36bf69624
commit
bcf2e64b19
@ -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<File>(JSON.parse(req.body["q"]));
|
||||
|
@ -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);
|
||||
|
Loading…
x
Reference in New Issue
Block a user