Commit d6e1920b authored by Vytor Calixto's avatar Vytor Calixto 👾
Browse files

Validação do tipo de arquivo no upload

parent c173cd2b
......@@ -14,7 +14,18 @@ var storage = multer.diskStorage({
})
}
})
var upload = multer({storage: storage})
var fileFilter = function(req, file, cb) {
console.log(file.mimetype)
if(file.mimetype === 'image/jpg' ||
file.mimetype === 'image/png' ||
file.mimetype === 'application/pdf') {
cb(null, true)
}
var err = new Error('Invalid file')
err.status = 400
cb(err)
}
var upload = multer({storage: storage, fileFilter: fileFilter})
var fs = require('fs')
var libs = process.cwd() + '/libs/'
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment