Uploading image to amazon s3 using multer-s3 nodejs

前端 未结 6 1916
遥遥无期
遥遥无期 2020-12-04 15:45

I am trying to upload an image to amazon s3 using multer-s3, but I am getting this error:

TypeError: Expected opts.s3 to be object node

6条回答
  •  眼角桃花
    2020-12-04 16:45

    s3 needs to be an object to be passed. According to the docs, the object needs to be like this:

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

    MulterS3 Docs

提交回复
热议问题