[英]How do I set metadata with aws s3api?
我正在嘗試使CloudFront托管的博客將/feed/atom/index.html
重定向到/index.xml
。 我有以下腳本應該為我設置重定向頭:
#!/bin/sh
redirect() aws s3api copy-object \
--copy-source blog.afoolishmanifesto.com$1 \
--bucket blog.afoolishmanifesto.com --key $1 \
--metadata x-amz-website-redirect-location=$2 \
--metadata-directive REPLACE
redirect /feed/atom/index.html /index.xml
運行腳本后,我得到以下輸出:
{
"CopyObjectResult": {
"LastModified": "2016-03-27T07:26:03.000Z",
"ETag": "\"40c27e3a5ea160c6695d7f34de8b4dea\""
}
}
而且,當我在S3的AWS控制台視圖中刷新對象時,沒有看到所涉及對象的Website Redirect Location
(或x-amz-website-redirect-location
)元數據。 如何確保重定向配置正確?
注意:我嘗試將元數據指定為JSON,據我所知,這沒有什么區別。
更新:我仍然保留上述問題,因為它仍然適用於元數據,但是如果您嘗試使用aws s3api創建重定向,則應使用--website-redirect-location
選項,而不是--metadata
。
它無法在存儲桶中創建鍵/feed/atom/index.html
,因此未創建元數據屬性。 相反,您應該創建feed/atom/index.html
。 我將其修改為:
#!/bin/sh
redirect() aws s3api copy-object \
--copy-source blog.afoolishmanifesto.com/$1 \
--bucket blog.afoolishmanifesto.com --key $1 \
--metadata x-amz-website-redirect-location=$2 \
--metadata-directive REPLACE
redirect feed/atom/index.html /index.xml
在我的解決方案中,請注意--copy-source
/
和用於重定向腳本的第一個參數缺少前導/
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.