I am using AWS SDK v2 and I have base64 images to upload back to my s3 bucket.
What I did :
source="data:image/png;base64,/9j/4SlqRXhpZgAASUkq....."
img_data=source.replace("data:image/png;base64,/", "");
var data = {
Key: directory+'/'+'test.jpeg',
Bucket: 'bucket',
Body: img_data ,
ContentEncoding: 'base64',
ContentType: 'image/jpeg'
};
s3.putObject(data, function(err, data){
if (err) {
console.log(err);
console.log('Error uploading data: ', data);
} else {
console.log('successfully uploaded the image!');
}
});
My image get successfully uploaded, but I can't open it. I guess my data is not correctly formatted. I don't know what to do more, and documentation is quite limited on this.
Any idea ?
Thanks !