Style-related operations
Image Service provides operations to create, read, update, and delete (CRUD) styles.
Put Style
You can create a style in a channel to save a set of complex image processing parameters. After you create the style, you can use it to apply the same image processing effects.
Request syntax
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
Parameter Name | Description | Required | Valid values |
styleName | The name of the style to create. | Yes | See Style naming conventions. |
Request elements
Parameter name | Description | Required | Valid values |
Content | The content of the style. This specifies the parameters used for image processing. | Yes | See Image processing parameters. |
Request example
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 qn6q**************:77Dv****************
<?xml version="1.0" encoding="UTF-8"?>
<Style>
<Content>100w_200h.jpg</Content>
</Style>Response example
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: AliyunOSSDetails
If the channel does not exist, a 404 Not Found error is returned. Error code: NoSuchChannel.
You can create a maximum of 50 styles in each channel. If you exceed this limit, a 403 Forbidden error is returned when you try to create a style. Error code: AccessDenied. Error message: Your style count exceeds 50.
Only the channel owner can create styles in that channel. If you try to create a style in a channel that you do not own, a 403 Forbidden error is returned. Error code: AccessDenied.
If the style that you want to create already exists, the existing style is updated.
List Style
You can use the List Style operation to retrieve information about all styles in a channel.
Request syntax
GET /?style HTTP/1.1
Host: ChannelName.img-cn-hangzhou.aliyuncs.com
Date: GMT Date
Authorization: SignatureValueResponse elements
Parameter name | Description |
Name | The name of the style. |
Content | The content of the style. |
CreateTime | The time when the style was created. |
LastModifyTime | The time when the style was last modified. |
Request example
GET /?style HTTP/1.1
Host: channel-example.img-cn-hangzhou.aliyuncs.com
Date: Thu, 08 Jan 2015 06:28:02 GMT
Authorization: OSS qn6q**************:77Dv****************Response example
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>Detailed analysis
If the channel does not exist, a 404 Not Found error is returned. Error code: NoSuchChannel.
Only the channel owner can list the styles in that channel. If you try to list styles in a channel that you do not own, a 403 Forbidden error is returned. Error code: AccessDenied.
Get Style
You can use the Get Style operation to retrieve the properties of a specific style. These properties include the style name, content, creation time, and last modified time.
Request syntax
GET /?style&styleName=YourStyleName HTTP/1.1
Host: ChannelName.img-cn-hangzhou.aliyuncs.com
Date: GMT Date
Authorization: SignatureValueRequest parameters
Parameter Name | Description | Required | Valid values |
styleName | The name of the style to get. | Yes | See Style naming conventions. |
Response elements
Parameter Name | Description |
Name | The name of the style. |
Content | The content of the style. |
CreateTime | The time when the style was created. |
LastModifyTime | The time when the style was last modified. |
Request example
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 qn6q**************:77Dv****************Response example
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>Detailed analysis
If the channel does not exist, a 404 Not Found error is returned. Error code: NoSuchChannel.
If the style does not exist, a 404 Not Found error is returned. Error code: NoSuchStyle.
Delete Style
You can use the Delete Style operation to delete a style.
Request syntax
DELETE /?style&styleName=YourStyleName HTTP/1.1
Host: ChannelName.img-cn-hangzhou.aliyuncs.com
Date: GMT Date
Authorization: SignatureValueRequest parameters
Parameter name | Description | Required | Valid values |
styleName | The name of the style to delete. | Yes | See Style naming conventions. |
Request example
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 qn6q**************:77Dv****************Response example
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: AliyunOSSIn-depth analysis
If the channel does not exist, a 404 Not Found error is returned. Error code: NoSuchChannel.
If the delete operation is valid, a 204 No Content response is returned, regardless of whether the style exists.
Only the channel owner can delete styles in that channel. If you try to delete a style in a channel that you do not own, a 403 Forbidden error is returned. Error code: AccessDenied.