function uploadPinMedia(req, res, next) {
var s3 = new AWS.S3({
accessKeyId: 'AKIAIUCBE3TQGL6ATPBA',
secretAccessKey: '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',
Bucket: 'mapery-v2'
});
var data = {
Bucket: 'mapery-v2',
Key: 'upload-v2',
Body: req.files.pin_img
};
s3.putObject(data, function(err, media_res) {
if(err)
console.log('error uploading data', media_res);
console.log(media_res);
});
}
req.files.pin_img
I am passing is not correct. Am I wrong anywhere ??
below works for me. make sure you have correct config. bucket. you'll found uploaded image using https://appname.s3-accelerate.amazonaws.com/aws_test.jpg
const AWS = require('aws-sdk');
AWS.config.update({
accessKeyId: process.env.AWS_KeyId,
secretAccessKey: process.env.AWS_secret,
// region:process.env.AWS_region
});
const s3 = new AWS.S3({ signatureVersion: 'v4', })
var photoBucket = new AWS.S3({
params: {
Bucket: 'bucket'
}
})
photoBucket.upload({
ACL: 'public-read',
Body: fs.createReadStream('./test.jpg'),
// file upload by below name
Key: 'aws_test.jpg',
ContentType: 'application/octet-stream' // force download if it's accessed as a top location
},(err, response)=>{
console.log(err, response)
});
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With