Carregue arquivos diferentes em diferentes pastas usando coberturas em nodejs
const multer = require('multer')const storage = multer.diskStorage({destination: (req, file, cb) => { const { userId } = req.body const dir = ./uploads/${userId} fs.exists(dir, exist => { if (!exist) { return fs.mkdir(dir, error => cb(error, dir)) } return cb(null, dir) })},filename: (req, file, cb) => { const { userId } = req.body cb(null, UserId-${userId}-Image-${Date.now()}.png)}})const upload = multer({ storage })
Sparkling Squirrel