How to limit the file size when uploading with multer?
I think it is you are looking.Have a great day.
const fileFilter = (req, file, cb) => {const fileSize = parseInt(req.headers['content-length']);if((file.mimetype === 'image/png' || file.mimetype === 'image/jpg' || file.mimetype === 'image/jpeg' || file.mimetype === 'application/octet-stream') && (fileSize <= 1282810)) {cb(null, true);} else if(file.mimetype === 'video/mp4' && fileSize <= 22282810) {cb(null, true);}else {cb(null, false);}
};