Monday, June 3, 2024
48
rated 0 times [  50] [ 2]  / answers: 1 / hits: 123410  / 11 Years ago, tue, may 28, 2013, 12:00:00

I was trying to download a file from a bucket on Amazon S3. I was wondering if I can write a javascript to download such a file from a bucket. I was googling it, but couldn't find any resources that can help me do that.



Some steps in mind are: authenticate Amazon S3, then by providing bucket name, and file(key), download or read the file so that I can be able to display the data in the file.



Thanks,


More From » amazon-web-services

 Answers
7

Maybe you can use AWS Node.js API:



var AWS = require('aws-sdk');
AWS.config.update(
{
accessKeyId: .. your key ..,
secretAccessKey: .. your secret key ..,
}
);
var s3 = new AWS.S3();
s3.getObject(
{ Bucket: my-bucket, Key: my-picture.jpg },
function (error, data) {
if (error != null) {
alert(Failed to retrieve an object: + error);
} else {
alert(Loaded + data.ContentLength + bytes);
// do something with data.Body
}
}
);

[#77960] Monday, May 27, 2013, 11 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
christianu

Total Points: 481
Total Questions: 124
Total Answers: 99

Location: Trinidad and Tobago
Member since Thu, Dec 1, 2022
2 Years ago
christianu questions
;