refactor: use fileSize limiternative to multer (#1209)

This commit is contained in:
Danny Avila 2023-11-22 18:42:21 -05:00 committed by GitHub
parent 5e6f8cbce7
commit 55cdd2eec6
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -29,13 +29,9 @@ const fileFilter = (req, file, cb) => {
);
}
if (file.size > sizeLimit) {
return cb(new Error(`File size exceeds ${sizeLimit / 1024 / 1024} MB.`), false);
}
cb(null, true);
};
const upload = multer({ storage, fileFilter });
const upload = multer({ storage, fileFilter, limits: { fileSize: sizeLimit } });
module.exports = upload;