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({
|
const upload = multer({
|
||||||
storage: storage,
|
storage,
|
||||||
limits: {
|
limits: { fileSize: 5 * 1024 * 1024 },
|
||||||
fileSize: 5 * 1024 * 1024, // max 5 MB
|
|
||||||
},
|
|
||||||
fileFilter: (req, file, cb) => {
|
fileFilter: (req, file, cb) => {
|
||||||
const ext = path.extname(file.originalname).toLowerCase();
|
if (!allowedMimeTypes.has(file.mimetype)) {
|
||||||
if (ext !== ".jpg" && ext !== ".jpeg" && ext !== ".png") {
|
|
||||||
return cb(new Error("Only JPG/JPEG/PNG images are allowed"), false);
|
return cb(new Error("Only JPG/JPEG/PNG images are allowed"), false);
|
||||||
}
|
}
|
||||||
cb(null, true);
|
cb(null, true);
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user