I am trying to upload a file to S3 using multer s3.However, it constantly fails.
aws.config.update({ secretAccessKey:'key', accessKeyId:'秘密', });
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'));
})
为什么我会这样做?