I am working on Nestjs Multer File Upload, I have created a file filter for FileInterceptor, I wanna send a response back instead of sending an error, I have to send a JSON with the message as "file type is not supported".
export const FileFilter = (req, file, callback) => {
if (!file.originalname.match(/\.(jpg|jpeg|png)$/)) {
return callback(new Error('Only image files supported!'), false);
}
callback(null, true);
}
Instead of sending new Error(), I would like to send
res.send({status:"error",message:"File types does not supported"});