How to set different destinations in nodejs using multer?

后端 未结 5 1855
你的背包
你的背包 2021-01-31 22:11

I\'m trying to upload any file using Multer package. It\'s working fine when I use following code in my server.js file.

var express         


        
5条回答
  •  日久生厌
    2021-01-31 22:41

    var storage = multer.diskStorage({
      destination: function (req, file, cb) {
        if (req.path.match('/pdf')) {
          cb(null,)
        }
      },
      filename: function (req, file, cb) {
      }
    })
    

    This works in case, the path is unique. You can modify (checking for the end point {req.path}) according to your needs. Though this solution is not dynamic.

提交回复
热议问题