I am trying to upload file into AWS S3 using node js.
My requirement is to use dynamic value for bucket in multerS3 storage object
storage: multerS3({
s3: s3,
bucket: function (req, file, cb) {
console.log(" bucketName is >> "+JSON.stringify(req.bucketName));
cb(null, req.bucketName)
},
limits : {
fileSize : Number(Constants.UPLOADED_IMAGE_SIZE)
},
metadata: function (req, file, cb) {
cb(null, { fieldName: file.fieldname });
},
key: function (req, file, cb) {
cb(null, file.originalname)
}
})
I am trying to pass value through request object and use it in bucket paramater. but it is coming as undefined.
in both cases req.bucketName and req.body.bucketName is coming as undefined.
Need help to resolve this problem.
My postman request is as below
Thanks for any help.