閱讀81 返回首頁    go 微信


樣式相關操作__樣式_老版圖片服務手冊_對象存儲 OSS-阿裏雲

圖片服務提供了一些 Style 相關的操作,用於增刪查改樣式(Style)。

Put Style

在某個頻道(Channel)下,創建一個樣式(Style),將複雜的圖片服務的處理參數,保存成一個樣式,創建樣式後,通過樣式實現與參數同樣的圖片處理效果。

請求語法

PUT /?style&styleName=YourStyleName  HTTP/1.1
Host: ChannelName.img-cn-hangzhou.aliyuncs.com
Date: GMT Date
Authorization: SignatureValue

<?xml version="1.0" encoding="UTF-8"?>
<Style>
<Content>100w_200h.jpg</Content>
</Style>

請求參數(Request Parameters)

參數名稱 說明 是否必須 取值範圍
styleName 待創建的Style的名稱 參見style命名規則

請求元素(Request Elements)

參數名稱 說明 是否必須 取值範圍
Content Style對應的內容,表示處理圖像所用的參數 參見圖像處理參數

請求示例

PUT /?style&styleName=style-example HTTP/1.1
Host: channel-example.img-cn-hangzhou.aliyuncs.com  
Date: Thu, 08 Jan 2015 06:17:55 GMT
Authorization: OSS 2onpuorvhikxergnrzmwkn0t:Hyc0UH+CXKQv6ExbZMi+HPn4Gxc=

<?xml version="1.0" encoding="UTF-8"?>
<Style>
<Content>100w_200h.jpg</Content>
</Style>

返回示例

HTTP/1.1 200 OK 
x-img-request-id: 54AE211379B222C77F000016
Date: Thu, 08 Jan 2015 06:17:55 GMT
Connection: close
Content-Length: 0  
Server: AliyunOSS

細節分析

  1. 如果Channel不存在,返回404 Not Found錯誤,錯誤碼:NoSuchChannel。
  2. 每個Channel下最多能創建50個Style。如果超過50個,Create Style時返回403 Forbidden錯誤,錯誤碼:AccessDenied,錯誤消息為:Your style count is exceeded 50.
  3. 隻有Channel的擁有者才能在該Channel下創建Style。如果試圖在一個不屬於自己的Channel下創建Style,返回403 Forbidden錯誤,錯誤碼:AccessDenied。
  4. 如果待創建的Style已經存在,則會更新原有的Style 。

List Style

List Style可以獲取某個頻道(Channel)下的所有樣式(Style)的信息。

請求語法

GET /?style HTTP/1.1
Host: ChannelName.img-cn-hangzhou.aliyuncs.com
Date: GMT Date
Authorization: SignatureValue

響應元素(Response Elements)

參數名稱 說明
Name Style名稱
Content Style對應的內容
CreateTime Style創建時間
LastModifyTime Style最後修改的時間

請求示例

GET /?style HTTP/1.1
Host: channel-example.img-cn-hangzhou.aliyuncs.com
Date: Thu, 08 Jan 2015 06:28:02 GMT
Authorization: OSS 2onpuorvhikxergnrzmwkn0t:zDI6c1trJAGHbR8rreyzq6lMq9U=

返回示例

HTTP/1.1 200 OK 
x-img-request-id: 54AE237279B222C77F000023
Date: Thu, 08 Jan 2015 06:28:02 GMT
Connection: close
Content-Type : application/xml
Content-Length: 568  
Server: AliyunOSS

<?xml version="1.0" encoding="UTF-8"?>
<StyleList>
  <Style>
    <Name>style-example1</Name>                    
    <Content>400w</Content>
    <CreateTime> Thu, 08 Jan 2015 06:28:02 GMT </CreateTime>               
    <LastModifyTime> Thu, 08 Jan 2015 06:28:02 GMT</LastModifyTime>
  </Style>
  <Style>
    <Name>style-example2</Name>                    
    <Content>400w</Content>
    <CreateTime>Thu, 08 Jan 2015 06:28:02 GMT</CreateTime>               
    <LastModifyTime> Thu, 08 Jan 2015 06:28:02 GMT</LastModifyTime>
  </Style>
</StyleList>

細節分析

  1. 如果頻道(Channel)不存在,返回404 Not Found錯誤,錯誤碼:NoSuchChannel。
  2. 隻有頻道(Channel)的擁有者才能List該頻道(Channel)下的樣式(Style)。如果試圖在一個不屬於自己的頻道(Channel)下List Style,返回403 Forbidden錯誤,錯誤碼:AccessDenied。

Get Style

Get Style可以獲取某個樣式(Style)的屬性信息,包括樣式名稱、內容,以及創建和最後修改時間。

請求語法:

GET /?style&styleName=YourStyleName HTTP/1.1
Host: ChannelName.img-cn-hangzhou.aliyuncs.com
Date: GMT Date
Authorization: SignatureValue

請求參數(Request Parameters)

參數名稱 說明 是否必須 取值範圍
styleName 需要獲取的Style的名稱 參見style命名規則

響應元素(Response Elements)

參數名稱 說明
Name Style名稱
Content Style對應的內容
CreateTime Style創建時間
LastModifyTime Style最後修改的時間

請求示例

GET /?style&styleName=style-example HTTP/1.1
Host: channel-example.img-cn-hangzhou.aliyuncs.com
Date: Thu, 08 Jan 2015 06:20:12 GMT
Authorization: OSS 2onpuorvhikxergnrzmwkn0t:SQe/ZdW92fmFgLEiIwsH4f8YTA8=

返回示例

HTTP/1.1 200 OK 
x-img-request-id: 54AB9937B703C78879000167 
Date: Thu, 08 Jan 2015 06:20:12 GMT
Connection: close
Content-Type : application/xml
Content-Length: 236  
Server: AliyunOSS

<?xml version="1.0" encoding="UTF-8"?>
<Style>
  <Name>jujht9w0d4</Name>
  <Content>erp2g2twla</Content>
  <CreateTime>Thu, 08 Jan 2015 06:20:12 GMT</CreateTime>
  <LastModifyTime>Thu, 08 Jan 2015 06:20:12 GMT</LastModifyTime>
</Style>

細節分析

  1. 如果頻道(Channel)不存在,返回404 Not Found錯誤,錯誤碼:NoSuchChannel。
  2. 如果樣式(Style)不存在,返回404 Not Found錯誤,錯誤碼:NoSuchStyle。

Delete Style

Delete Style用來刪除某個樣式(Style)。

請求語法

DELETE /?style&styleName=YourStyleName HTTP/1.1
Host: ChannelName.img-cn-hangzhou.aliyuncs.com
Date: GMT Date
Authorization: SignatureValue

請求參數(Request Parameters)

參數名稱 說明 是否必須 取值範圍
styleName 待刪除的Style的名稱 參見style命名規則

請求示例

DELETE /?style&styleName=style-example HTTP/1.1
Host: channel-example.img-cn-hangzhou.aliyuncs.com
Date: Thu, 08 Jan 2015 06:30:20 GMT
Authorization: OSS 2onpuorvhikxergnrzmwkn0t:mK217ZMjVP30w4Q99vYwBEgddqw=

返回示例

HTTP/1.1 204 No Content
x-img-request-id: 54AE23FC79B222C77F000028
Date: Thu, 08 Jan 2015 06:30:20 GMT
Connection: close
Content-Length: 0  
Server: AliyunOSS

細節分析

  1. 如果頻道(Channel)不存在,返回404 Not Found錯誤,錯誤碼:NoSuchChannel。
  2. 不管樣式(Style)存不存在,隻要刪除操作合法,刪除成功後都會返回204 No Content。
  3. 隻有頻道(Channel)的擁有者才能刪除該頻道下的樣式(Style)。如果試圖刪除一個不屬於自己的頻道下的樣式,返回403 Forbidden錯誤,錯誤碼:AccessDenied。

最後更新:2016-11-23 16:04:11

  上一篇:go 樣式訪問__樣式_老版圖片服務手冊_對象存儲 OSS-阿裏雲
  下一篇:go OSS怎麼更改Object元數據信息__數據操作常見問題_產品使用問題_對象存儲 OSS-阿裏雲