Setting content-disposition in S3

sweemeng
2 min readFeb 19, 2023

Not too long ago, I had this problem. We need to allow users to download json files hosted S3 through a signed URL, but the user on browser will see their json file rendered on the browser instead.

The behavior of whether a file to be downloaded or rendered on a browser is determined by Content-Disposition response header. The default behavior on S3 is Content-Disposition: inline. This tells the browser to render the content on the browser, but if it is a binary file then download.

--

--

sweemeng

Codemonkey coding for tea. Startup developer at day, community organizer at night. I also happens to be on patreon https://www.patreon.com/sweemeng