I am trying to upload my files to my Amazon S3 bucket. In my research I got this link which worked fine and the files got uploaded:
https://github.com/zishon89us/node-cheat/tree/master/aws/express_multer_s3
But I need to concatenate this to my web services which the request will have the Json form data, so I have tried this:
aws.config.update({
secretAccessKey: 'mysecretkey',
accessKeyId: 'my access key',
});
s3 = new aws.S3();
/**multer function*/
var transfer = multerS3({
s3: s3,
bucket: 'mu_bucket_name',
key: function (req, file, cb) {
console.log("cb");
var newFileName = Date.now() + "-" + file.originalname;
var fullPath = 'path/'+ newFileName;
cb(null, fullPath); //use Date.now() for unique file keys
console.log(fullPath);
console.log("I am getting till this console")
}
});
var upload = multer({storage:transfer}).any();
upload(req,res, function (err,res) {
console.log("req");
console.log(err);
console.log(res);
})
Above is my code and I am getting no response in:
upload(req,res, function (err,res) {
console.log("req");
console.log(err);
console.log(res);
})
But I am getting the:
console.log(fullPath);
as:
'path/1499786601509-S.mp4'
Any help? I am not getting any response and file is not getting uploaded.