1

I will get all the s3 bucket object URL in the Console. How to download that object from client side using Angularjs

app.controller('Sample', function($scope) {

   AWS.config.update({
       accessKeyId: '',
       secretAccessKey: ''
   });

   AWS.config.region = "us-east-1";
   $scope.s3Url = '';

   var bucket = new AWS.S3({
      params: {
         Bucket: 'mybucketname',
         Prefix: 'UPLOADS'
      }
   });

   bucket.listObjects(function(err, data) {
     if (err) {
        console.log(err);
     } else {
        console.log(data.Contents[1]);
        $scope.imgData = $scope.s3Url + data.Contents[1].Key;
        console.log($scope.imgData);
     }
   });

});
1

1 Answer 1

1

Hope this will help you. This works on chrome and firefox but not sure on other browser.

let link = document.createElement('a');
link.href = 's3_url_image.png';
link.download = 'download_filename.png';
document.body.appendChild(link);
link.click();
Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.