[英]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.我有一个 test.txt 文件存储在 S3 存储桶中,当我单击“打开”时,我希望它被下载,但它正在浏览器本身中打开。 I have tried setting Content-disposition to attachment but it did not work.
我尝试将 Content-disposition 设置为附件,但它不起作用。 Is there any way to force download text and json files from S3?
有什么方法可以强制从 S3 下载文本和 json 文件? Thanks in advance.
提前致谢。
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
.当您在 S3 控制台中单击
Open
时,它会将response-content-disposition=inline
发送到 S3,这会将 object 上设置的任何Content-Disposition
覆盖到inline
。 Content-Disposition: inline
indicates that the content of this file can be displayed inside the Web page. Content-Disposition: inline
表示该文件的内容可以显示在Web页面内部。 This is why setting Content-Disposition
won't work in this case.这就是为什么在这种情况下设置
Content-Disposition
不起作用的原因。
If you need to download the file (instead of opening it in the web page) from the S3 console, you can either如果您需要从 S3 控制台下载文件(而不是在 web 页面中打开它),您可以
Open
Open
Save as...
Save as...
Or或者
Download as
in the S3 web consoleDownload as
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.