Javascript code to download a file from Amazon S3

0 votes

Is there a javascript code to download a file from Amazon S3? I couldn't find anything useful resources on the internet. So, if any of you have done something similar to this can you post the code?  Well, is it possible to write a javascript code to download a file from S3?

Dec 31, 2018 in AWS by datageek
• 3,040 points
1,401 views

1 answer to this question.

0 votes

Hai, I was thinking along the same lines. Then I figured out I could make use of node.js, ie. use AWS SDK for javascript in node.js.

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");
    }
  }
);
Try this out!
answered Dec 31, 2018 by Archana
• 5,560 points

Related Questions In AWS

0 votes
1 answer
0 votes
1 answer

How to copy .csv file from Amazon S3 bucket?

Boto3 is the library to use for ...READ MORE

answered Jul 6, 2018 in AWS by Priyaj
• 56,520 points
381 views
0 votes
1 answer
–1 vote
1 answer

How to read a csv file stored in Amazon S3 using csv.DictReader

The code would be something like this: import ...READ MORE

answered Oct 25, 2018 in AWS by Archana
• 5,560 points
7,381 views