Creates a named image style for a bucket. An image style saves one or more image processing parameters as a reusable preset, so you reference the style name in requests instead of repeating the full parameter string.
Prerequisites
Before you run this command, ensure that you have:
An OSS bucket
The
oss:PutStylepermission (required for RAM users and STS credentials)
By default, an Alibaba Cloud account can manage image styles in its own buckets. To run this command as a RAM user or with Security Token Service (STS) credentials, grant the oss:PutStyle permission first. For details, see Attach a custom policy to a RAM user.
Command syntax
ossutil api put-style --bucket <bucket-name> --style-name <style-name> --style <style-config> [flags]Required parameters
| Parameter | Type | Description |
|---|---|---|
--bucket | string | The bucket name. |
--style-name | string | The name to assign to the image style. |
--style | string | The image processing parameters to save. Pass an XML or JSON string directly, or load from a file using the file:// prefix. |
This command is the ossutil equivalent of the PutStyle API operation. For supported global flags, see Global command-line options.
--style format
Pass the style configuration as an inline string or load it from a file using the file:// prefix.
XML format:
<Style>
<Content>string</Content>
</Style>JSON format:
{
"Content": "string"
}To load from a file, set the value to file://<path-to-file>. For example: --style file://style.xml.
Examples
The following examples create an image style named imageStyle for a bucket named examplebucket, using image/resize,p_50 as the style content. Each example shows a different way to pass the --style parameter.
Load from an XML file (`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.xmlLoad from a JSON file (`style.json`):
{
"Content": "image/resize,p_50"
}ossutil api put-style --bucket examplebucket --style-name imageStyle --style file://style.jsonPass JSON inline:
ossutil api put-style --bucket examplebucket --style-name imageStyle --style "{\"Content\":\"image/resize,p_50\"}"