S3 网页重定向:无法设置 x-amz-website-redirect-location 属性 [英] S3 web page redirect: can't set x-amz-website-redirect-location property
问题描述
我想对 S3 网页使用重定向.AWS 配置网页重定向 文档说要设置 x-amz-website-redirect-location
属性,但这似乎不可设置.如果我尝试设置密钥,S3 会在密钥前面加上 x-amz-meta-
(使其成为 用户定义的元数据)并且修改后的键不会导致重定向.
I want to use redirects with S3 webpages. The AWS Configuring a Web Page Redirect document says to set the x-amz-website-redirect-location
property, but this doesn't seem to be settable. If I try to set the key, S3 prefixes the key with x-amz-meta-
(making it a user-defined metadata) and the modified key doesn't cause a redirect.
我使用 aws CLI 设置元数据:
I set the metadata with the aws CLI:
aws s3api copy-object --copy-source static.righto.com/zero \
--bucket static.righto.com --key bar \
--metadata x-amz-website-redirect-location=http://righto.com/bar \
--metadata-directive REPLACE
但是当我查看 S3 控制台时,元数据名称已添加前缀并且重定向被忽略.
but when I look in the S3 console, the metadata name has been prefixed and the redirect is ignored.
如果我使用 Python API,也会发生同样的事情:
The same thing happens if I use the Python API:
s3.Bucket('static.righto.com').put_object(Key=src, Body='',
Metadata={'x-amz-website-redirect-location': dst})
如果我尝试在 S3 控制台中设置 x-amz-website-redirect-location
元数据键,我会收到错误用户定义的元数据键必须以 x-amz- 开头元-."
And if I try to set the x-amz-website-redirect-location
metadata key in the S3 console, I get the error "User-defined metadata keys must start with x-amz-meta-."
x-amz-website-redirect-location
是否不受支持?
如果我在控制台中设置网站重定向位置"元数据然后重定向工作,那么问题不是 这个答案.但我不能使用网站重定向位置"作为 API 中的元数据键.
If I set "Website Redirect Location" metadata in the console then redirects work, so issue isn't the redirect endpoint problems in this answer. But I can't use "Website Redirect Location" as a metadata key in the API.
推荐答案
使用--website-redirect-location
.
http://docs.aws.amazon.com/cli/latest/reference/s3api/copy-object.html
x-amz-website-redirect-location
不是 user 元数据 (x-amz-meta-*
),这就是--metadata
选项用于.
x-amz-website-redirect-location
is not user metadata (x-amz-meta-*
), which is what the --metadata
option is used for.
这篇关于S3 网页重定向:无法设置 x-amz-website-redirect-location 属性的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!