put-object-tagging用於設定或更新對象(Object)的標籤(Tagging)資訊。
注意事項
阿里雲帳號預設擁有設定或更新對象的標籤的許可權。如果您需要通過RAM使用者或者STS的方式進行設定或更新,您必須擁有
oss:PutObjectTagging許可權。具體操作,請參見為RAM使用者授權自訂的權限原則。對象標籤使用一組索引值對(Key-Value)標記對象。單個Object最多能設定10個標籤,Key不能重複。每個Key長度不能超過128字元,每個Value長度不能超過256字元。Key和Value區分大小寫。標籤的合法字元集包括大小寫字母、數字、空格和以下符號:
+‑=._:/。更改標籤資訊不會更新Object的Last-Modified時間。
命令格式
ossutil api put-object-tagging --bucket value --key value --tagging value [flags]參數 | 類型 | 說明 |
--bucket | string | Bucket名稱。 |
--key | string | Object完整路徑。 |
--tagging | string | 標籤集合。 |
--version-id | string | Object的版本號碼。 |
說明
put-object-tagging命令對應API介面PutObjectTagging。關於API中的具體參數含義,請參見PutObjectTagging。
--tagging
--tagging配置選項既支援XML文法也支援JSON文法,當選項值包含file://首碼時,表示從檔案中讀取配置。
XML文法:
<Tagging> <TagSet> <Tag> <Key>string</Key> <Value>string</Value> </Tag> ... </TagSet> </Tagging>JSON文法:
{ "TagSet": { "Tag": [ { "Key": "string", "Value": "string" }, ... ] } }
說明
關於支援的全域命令列選項,請參見支援的全域命令列選項。
使用樣本
為對象exampleobject添加或修改標籤。
使用XML設定檔,tagging.xml內容如下:
<?xml version="1.0" encoding="UTF-8"?> <Tagging> <TagSet> <Tag> <Key>key1</Key> <Value>value1</Value> </Tag> <Tag> <Key>key2</Key> <Value>value2</Value> </Tag> </TagSet> </Tagging>命令樣本如下:
ossutil api put-object-tagging --bucket examplebucket --key exampleobject --tagging file://tagging.xml使用JSON設定檔,tagging.json內容如下:
{ "TagSet": { "Tag": [ { "Key": "key1", "Value": "value1" }, { "Key": "key2", "Value": "value2" } ] } }命令樣本如下:
ossutil api put-object-tagging --bucket examplebucket --key exampleobject --tagging file://tagging.json使用JSON配置參數,命令樣本如下:
ossutil api put-object-tagging --bucket examplebucket --key exampleobject --tagging "{\"TagSet\":{\"Tag\":[{\"Key\":\"key1\",\"Value\":\"value1\"},{\"Key\":\"key2\",\"Value\":\"value2\"}]}}"