diff options
Diffstat (limited to 'server')
-rw-r--r-- | server/lib/middleware.js | 14 |
1 files changed, 13 insertions, 1 deletions
diff --git a/server/lib/middleware.js b/server/lib/middleware.js index 735fddb..292c372 100644 --- a/server/lib/middleware.js +++ b/server/lib/middleware.js @@ -21,7 +21,19 @@ const multerStorage = multer.diskStorage({ cb(null, uuid.v4() + path.extname(file.originalname)); } }); -const upload = multer({storage: multerStorage}); +const multerFileFilter = (req, file, cb) => { + if (file.mimetype === 'image/png' || file.mimetype === 'image/jpeg' || file.mimetype === 'image/jpg') + cb(null, true); + else + cb(null, false); +}; +const upload = multer({ + storage: multerStorage, + limits: { + fileSize: 1024 * 1024 * 10 //10MB + }, + fileFilter: multerFileFilter +}); module.exports = { |