collection added
This commit is contained in:
parent
9224594a28
commit
d7b5a0a415
@ -17,14 +17,17 @@ const storage = multer.diskStorage({
|
||||
},
|
||||
});
|
||||
|
||||
const allowedMimeTypes = new Set([
|
||||
"image/jpeg",
|
||||
"image/png",
|
||||
"image/jpg",
|
||||
]);
|
||||
|
||||
const upload = multer({
|
||||
storage: storage,
|
||||
limits: {
|
||||
fileSize: 5 * 1024 * 1024, // max 5 MB
|
||||
},
|
||||
storage,
|
||||
limits: { fileSize: 5 * 1024 * 1024 },
|
||||
fileFilter: (req, file, cb) => {
|
||||
const ext = path.extname(file.originalname).toLowerCase();
|
||||
if (ext !== ".jpg" && ext !== ".jpeg" && ext !== ".png") {
|
||||
if (!allowedMimeTypes.has(file.mimetype)) {
|
||||
return cb(new Error("Only JPG/JPEG/PNG images are allowed"), false);
|
||||
}
|
||||
cb(null, true);
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user