dimanche 2 mai 2021

Uploading a file using multer in Node JS

Can you please explain in detail what is happening in these lines of code? Why we are storing a function in the object with a callback?

var storage = multer.diskStorage({


destination: function (req, file, cb) {
    cb(null, '/tmp/my-uploads')
  },
  filename: function (req, file, cb) {
    cb(null, file.fieldname + '-' + Date.now())
  }
})
 
var upload = multer({ storage: storage })



Aucun commentaire:

Enregistrer un commentaire