3
I am trying to upload a file to S3 using multer s3.However, it constantly fails.

aws.config.update({ secretAccessKey: 'key', accessKeyId: 'secret', });

var s3 = new aws.S3()

var upload = multer({
  storage: multerS3({
    s3: s3,
    bucket: 'pdsfiles',
    metadata: function (req, file, cb) {
      cb(null, {fieldName: file.fieldname});
    },
    key: function (req, file, cb) {
      cb(null, Date.now().toString())
    }
  })
})

这是错误的样子:

TypeError: this.s3.upload is not a function
at S3Storage. (/home/simran/Downloads/NODE-BACKEND/node_modules/multer-s3/index.js:172:26)
at /home/simran/Downloads/NODE-BACKEND/node_modules/multer-s3/index.js:58:10
at S3Storage.getContentType (/home/simran/Downloads/NODE-BACKEND/node_modules/multer-s3/index.js:8:5)
at /home/simran/Downloads/NODE-BACKEND/node_modules/multer-s3/index.js:55:13
at end (/home/simran/Downloads/NODE-BACKEND/node_modules/run-parallel/index.js:16:15)
at _combinedTickCallback (internal/process/next_tick.js:73:7)
at process._tickDomainCallback (internal/process/next_tick.js:128:9)

称呼:

router.put('/updatePatternGrading/:pattern_number', upload.any(), function(req, res){
     console.log("request obj after manipulation", req.files);
     callAPI(req, res, fn.bind(apiObj, 'updatePatternGrading'));
 })

为什么我会得到这个?

4

0 回答 0