Prathibha Nag
Prathibha Nag

Reputation: 41

How to force download text files from AWS S3 bucket

I have a test.txt file stored in an S3 bucket and when i click on "Open", i want it to get downloaded but it is opening in the browser itself. I have tried setting Content-disposition to attachment but it did not work. Is there any way to force download text and json files from S3? Thanks in advance.

Upvotes: 0

Views: 2761

Answers (1)

jellycsc
jellycsc

Reputation: 12259

When you click Open in the S3 console, it sends response-content-disposition=inline to S3 which overwrites whatever Content-Disposition set on the object to inline. Content-Disposition: inline indicates that the content of this file can be displayed inside the Web page. This is why setting Content-Disposition won't work in this case.

If you need to download the file (instead of opening it in the web page) from the S3 console, you can either

  • click Open
  • on the new popup page, right click and choose Save as ...

Or

  • click Download as in the S3 web console

Upvotes: 1

Related Questions