全部產品
Search
文件中心

Object Storage Service:put-style

更新時間:Sep 10, 2024

put-style用於新增圖片樣式。一個圖片樣式中可以包含單個或多個圖片處理參數。

注意事項

阿里雲帳號預設擁有對Bucket中圖片處理的許可權。如果您需要通過RAM使用者或者STS的方式進行處理,您必須擁有oss:PutStyle許可權。具體操作,請參見為RAM使用者授權自訂的權限原則

命令格式

ossutil api put-style --bucket value --style-name value --style value [flags]

參數

類型

說明

--bucket

string

Bucket名稱。

--style

string

儲存Content資訊列表的容器。

--style-name

string

圖片樣式名稱。

說明

put-style命令對應API介面PutStyle。關於API中的具體參數含義,請參見PutStyle

--style

--style配置選項既支援XML文法也支援JSON文法,當選項值包含file://首碼時,表示從檔案中讀取配置。

  • XML文法:

    <Style>
     <Content>string</Content>
    </Style>
  • JSON文法:

    {
      "Content": "string"
    }
說明

關於支援的全域命令列選項,請參見支援的全域命令列選項

使用樣本

新增儲存空間examplebucket樣式名稱為imageStyle圖片樣式。

  • 使用XML設定檔,style.xml內容如下:

    <?xml version="1.0" encoding="UTF-8"?>
    <Style>
      <Content>image/resize,p_50</Content>
    </Style>

    命令樣本如下:

    ossutil api put-style --bucket examplebucket --style-name imageStyle --style file://style.xml
  • 使用JSON設定檔,style.json內容如下:

    {
      "Content": "image/resize,p_50"
    }

    命令樣本如下:

    ossutil api put-style --bucket examplebucket --style-name imageStyle --style file://style.json
  • 使用JSON配置參數,命令樣本如下:

    ossutil api put-style --bucket examplebucket --style-name imageStyle --style "{\"Content\":\"image/resize,p_50\"}"