How to generate a download link for a file present in amazon S3 using python boto? I tried (key.generate_url). But it is opening the .txt file in browser instead of download.
When creating the URL, you should specify a "content disposition" response header:
headers = {'response-content-disposition': 'attachment; filename="your-filename.txt"'}
url = key.generate_url(expires_in=600, response_headers=headers)
When the URL is used , it will cause S3 to return a Content-Disposition header that will indicate to the browser that it should download the file instead of display it directly.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.