提问人:toomanylogins 提问时间:8/25/2023 最后编辑:toomanylogins 更新时间:8/25/2023 访问量:32
S3 重定向 AWS JavaScript 开发工具包。附加到 x-amz-website-redirect-location 的 x-amz-meta
s3 redirect aws javascript sdk. x-amz-meta appended to x-amz-website-redirect-location
问:
我正在尝试将对象放入 S3 进行重定向。我可以毫无问题地创建对象,但是在设置元数据时,301 重定向不起作用。元数据密钥已创建,但这是用户定义的,而不是系统定义的。用户定义的元数据以 x-awz-meta 开头,系统定义的数据是 x-amz。
因此,系统定义的重定向键是 x-amz-website-redirect-location,但似乎您无法使用 JavaScript SDK 创建它。当您设置元数据时,AWS 会附加用户定义的前缀。
有了这个代码。
command = new PutObjectCommand({
Bucket: bucketParams.Bucket,
Key: cliParams.routingRules[0].old_url,
Body: '',
Metadata: {
'x-amz-website-redirect-location': cliParams.routingRules[0].new_url`
}
});
创建的密钥是用户定义为 x-amz-meta-x-amz-website-redirect-location。如果我省略 x-amz 前缀。
command = new PutObjectCommand({
Bucket: bucketParams.Bucket,
Key: cliParams.routingRules[0].old_url,
Body: '',
Metadata: {
'website-redirect-location': cliParams.routingRules[0].new_url
}
});
创建的密钥是用户定义为 x-amz-meta-website-redirect-location。带有 x-amz-meta 的密钥不会 301 重定向。
密钥需要系统定义,即 x-amz-website-redirect-location。
有人知道如何设置这个吗? 谢谢
我尝试将元数据键设置为每个选项。相同的结果始终获取用户定义的元数据键
答:
0赞
toomanylogins
8/25/2023
#1
此作品不使用元数据
command = new PutObjectCommand({
Bucket: bucketParams.Bucket,
Key: cliParams.routingRules[0].old_url,
Body: '',
WebsiteRedirectLocation:cliParams.routingRules[0].new_url
});
评论