更改现有 S3 对象的内容配置 [英] Change Content-Disposition of existing S3 object
问题描述
在 S3 REST API 中,我使用 PUT(复制)命令将元数据添加到现有对象,并将密钥复制到与 'x-amz-metadata-directive' = 'REPLACE' 相同的位置代码>
In S3 REST API I am adding metadata to an existing object by using the PUT (Copy) command and copying a key to the same location with 'x-amz-metadata-directive' = 'REPLACE'
我想要做的是通过设置更改下载文件名:
What I want to do is change the download file name by setting:
Content-Disposition: attachment; filename=foo.bar;
这正确设置了元数据,但是当我下载文件时它仍然使用密钥名称而不是foo.bar"
我使用软件工具 S3 浏览器查看元数据,它看起来是正确的(除了 'Content-Disposition'
都是小写的,因为这是 S3 问我签字)
I use a software tool S3 Browser to view the metadata and it looks correct (apart from 'Content-Disposition'
being all lower case as that's was S3 ask me to sign)
然后使用我刚刚按下的 S3 浏览器,然后保存而不更改任何内容,现在它可以工作了???
Then using S3 Browser I just pressed, then save without changing anything and now it works???
我错过了什么如何设置元数据 'Content-Disposition:attachment;filename=foo.bar;'
来自我的网络应用程序不起作用,但可以从 S3 浏览器工作?
What am I missing how come setting a metadata 'Content-Disposition: attachment; filename=foo.bar;'
from my web app does not work but does work from S3 Browser?
推荐答案
为清晰起见进行了
Content-Disposition 必须明确设置,而不是作为 x-amz-meta-Content-Disposition
包含.所有元数据头名称必须以x-amz-meta-"开头,并且全部小写.
Content-Disposition must be set explicitly and not included as x-amz-meta-Content-Disposition
. All metadata header names must start with "x-amz-meta-" and be all lowercase.
感谢@Eyal 的澄清.
Thanks to @Eyal for clarifying.
原文:
>SOLVED:
>
>The Doco at http://docs.amazonwebservices.com/AmazonS3/latest/dev/index.html?RESTAuthentication.html
>
>seems to be wrong it says:
>
>Notice how the 'x-amz-' headers are sorted, white-space trimmed, converted tolowercase, and multiple headers with the same name have been joined using a comma toseparate values.
>
>Note how only the Content-Type and Content-MD5HTTPentity headers appear in the StringToSign .The otherContent-* entity headers do not.
However Content-Disposition must be set specifically and not included as : x-amz-meta-Content-Disposition
>
>It now works fine.
这篇关于更改现有 S3 对象的内容配置的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!