Search code examples
amazon-web-servicesamazon-s3

website page command (and syntax) to download file from AWS s3 to user's download bucket


I have a website and a file on AWS s3. When a button on the website is clicked, I would like the file in the s3 bucket to be downloaded to the user's download bucket. The AWS docs say to use one of 4 options to download (s3 console, AWS CLI, AWS SDK, Rest API)[ [aws]].

I assumed the CLI is the way to proceed and tried (no errors, just doesn't work):

aws s3api get-object --bucket abcde --key folder/version/current/xyzapp.exe %userprofile%\downloads

Questions:

  1. Is the CLI the way to proceed? If so, do I need to embed AWS CLI onto the webpage somehow?
  2. What is the proper syntax (quotes, spaces, etc.) for the webpage code
  3. Is the user's download bucket path correct?

1


Solution

  • They can access it via the URL, like this:

    https://abcde.s3.ap-southeast-2.amazonaws.com/folder/version/current/xyzapp.exe
    

    However, this would require the bucket to be made Public, or the object to be made Public.

    Alternatively, you can keep everything private and generate an Amazon S3 pre-signed URL, which provides time-limited access to private objects in Amazon S3.