All Products
Search
Document Center

Object Storage Service:put-style

Last Updated:Sep 10, 2024

Creates an image style. An image style contains one or more image processing parameters.

Usage notes

By default, an Alibaba Cloud account has permissions to process images in buckets owned by the account. To use process images as a RAM user or by using access credentials provided by Security Token Service (STS), you must have the oss:PutStyle permission. For more information, see Attach a custom policy to a RAM user.

Command syntax

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

Parameter

Type

Description

--bucket

string

The name of the bucket.

--style

string

The container that stores the image style configurations.

--style-name

string

The name of the image style.

Note

The put-style command is the equivalent of the PutStyle operation. For more information about the API operation, see PutStyle.

--style

The --style parameter supports XML and JSON formats. If the value of the parameter starts with "file://", the configurations are loaded from the specified file.

  • XML format:

    <Style>
     <Content>string</Content>
    </Style>
  • JSON syntax:

    {
      "Content": "string"
    }
Note

For more information about supported global command-line options, see Global command-line options.

Examples

Create an image style named imageStyle for a bucket named examplebucket.

  • Use an XML configuration file (style.xml in this example)

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

    Sample command:

    ossutil api put-style --bucket examplebucket --style-name imageStyle --style file://style.xml
  • Use a JSON configuration file (style.json in this example)

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

    Sample command:

    ossutil api put-style --bucket examplebucket --style-name imageStyle --style file://style.json
  • Use JSON parameters in the command line

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