multer change file original name code example
Example: multer rename file
const multer = require('multer')
const storage = multer.diskStorage({
destination: function (req, file, cb) {
cb(null, 'uploads/')
},
filename: function (req, file, cb) {
cb(null, file.filename + '-' + Date.now()
}
})
const upload = multer({ storage: storage })
router.route('/upload').post(upload.single('file'), (req, res, next) => { return res.json(req.file) })
router.route('/upload').post(upload.array('file[]'), (req, res, next) => { return res.json(req.file) })