collection added

This commit is contained in:
Jonathan Jara 2025-06-06 00:32:14 -07:00
parent 9224594a28
commit d7b5a0a415

View File

@ -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);