Right now I am checking the file size and blocking any further action.
if (req.file.size > 4000000) {
return "Image too big";
}
But the file is still downloaded. Sure I can delete it but how can I prevent the file from being downloaded by the server if it's over a certain size without downloading the file?
EDIT: The reason body-parser limit didn't work for me is because I'm using multer.
Solution:
const upload = multer({ dest: "uploads/", limits: { fileSize: 4000000 } });