All Products
Search
Document Center

Object Storage Service:style

Last Updated:Apr 01, 2024

You can use the style command to configure image styles.

Usage notes

  • To configure an image style, you must have the oss:PutStyle permission. To query an image style, you must have the oss:GetStyle permission. To delete an image style, you must have the oss:DeleteStyle permission. For more information, see Attach a custom policy to a RAM user.

  • Sample command lines in this topic are based on the 64-bit Linux system. For other systems, replace ./ossutil64 in the commands with the corresponding binary name. For more information, see ossutil command reference.

  • Only ossutil 1.7.16 and later support the style command.

Configure image styles

  • Command syntax

    ./ossutil64 style --method put oss://bucketname/ stylename local_xml_file

    The following table describes the parameters in the preceding command.

    Parameter

    Description

    bucketname

    The name of the bucket for which you want to configure image styles.

    stylename

    The name of the image style.

    local_xml_file

    The name of the local file that is used to configure the image style, such as config.xml.

  • Examples

    1. Configure the image style file in a local XML file.

      <?xml version="1.0" encoding="UTF-8"?>
      <Style>
       <Content>image/resize,p_50</Content>
      </Style>
    2. The following code provides an example on how to configure an image style named examplestyle for a bucket named examplebucket:

      ./ossutil64 style --method put oss://examplebucket/ examplestyle config.xml

      The following output is returned:

      0.299514(s) elapsed

Query image styles

  • Command syntax

    ./ossutil64 style --method get oss://bucketname/ stylename local_xml_file

    The following table describes the parameters in the preceding command.

    Parameter

    Description

    bucketname

    The name of the bucket whose image styles you want to query.

    stylename

    The name of the image style.

    local_xml_file

    The name of the local file in which the image styles are stored, such as config.xml.

  • Examples

    • The following code provides an example on how to query an image style named examplestyle of a bucket named examplebucket and list the query results:

      ./ossutil style --method get oss://examplebucket/ examplestyle

      The following output is returned:

      <?xml version="1.0" encoding="UTF-8"?>
      <Style>
        <Name>examplestyle</Name>
        <Content>image/resize,p_100</Content>
        <CreateTime>Thu, 22 Dec 2022 13:59:06 GMT</CreateTime>
        <LastModifyTime>Thu, 22 Dec 2022 13:59:06 GMT</LastModifyTime>
      </Style>
      
      
      
      0.150473(s) elapsed
    • The following code provides an example on how to store an image style named examplestyle of a bucket named examplebucket as a local file:

      ./ossutil style --method get oss://examplebucket/ examplestyle local.xml

      The following output is returned:

      • The following result is displayed:

        0.214483(s) elapsed
      • The local file contains the following content:

        <?xml version="1.0" encoding="UTF-8"?>
        <Style>
          <Name>examplestyle</Name>
          <Content>image/resize,p_100</Content>
          <CreateTime>Thu, 22 Dec 2022 13:59:06 GMT</CreateTime>
          <LastModifyTime>Thu, 22 Dec 2022 13:59:06 GMT</LastModifyTime>
        </Style>

Delete image styles

  • Command syntax

    ./ossutil64 style --method delete oss://bucketname/ stylename 

    The following table describes the parameters in the preceding command.

    Parameter

    Description

    bucketname

    The name of the bucket whose image styles you want to delete.

    stylename

    The name of the image style.

  • Examples

    The following code provides an example on how to delete an image style named examplestyle from a bucket named examplebucket:

    ./ossutil style --method delete oss://examplebucket examplestyle

    The following output is returned:

    0.184183(s) elapsed

List image styles

  • Command syntax

    ./ossutil64 style --method list oss://bucketname/ local_xml_file

    The following table describes the parameters in the preceding command.

    Parameter

    Description

    bucketname

    The name of the bucket whose image styles you want to list.

    local_xml_file

    The name of the local file in which the image styles are stored, such as config.xml.

  • Examples

    • The following code provides an example on how to list the image styles of a bucket named examplebucket and display the list results:

      ./ossutil style --method list oss://examplebucket/

      The following output is returned:

      <?xml version="1.0" encoding="UTF-8"?>
      <StyleList>
        <Style>
          <Name>examplestyle1</Name>
          <Content>image/resize,p_100</Content>
          <CreateTime>Thu, 22 Dec 2022 13:59:06 GMT</CreateTime>
          <LastModifyTime>Thu, 22 Dec 2022 13:59:06 GMT</LastModifyTime>
        </Style>
        <Style>
          <Name>examplestyle2</Name>
          <Content>image/resize,p_100</Content>
          <CreateTime>Thu, 22 Dec 2022 13:59:06 GMT</CreateTime>
          <LastModifyTime>Thu, 22 Dec 2022 13:59:06 GMT</LastModifyTime>
        </Style>
      </StyleList>
      
      0.155333(s) elapsed
    • The following code provides an example on how to list the image styles of a bucket named examplebucket and store the image styles as a local file:

      ./ossutil style --method list oss://examplebucket/ local.xml

      The following output is returned:

      • The following result is displayed:

        2.655387(s) elapsed
      • The local file contains the following content:

        <?xml version="1.0" encoding="UTF-8"?>
        <StyleList>
          <Style>
            <Name>examplestyle1</Name>
            <Content>image/resize,p_100</Content>
            <CreateTime>Thu, 22 Dec 2022 13:59:06 GMT</CreateTime>
            <LastModifyTime>Thu, 22 Dec 2022 13:59:06 GMT</LastModifyTime>
          </Style>
          <Style>
            <Name>examplestyle2</Name>
            <Content>image/resize,p_100</Content>
            <CreateTime>Thu, 22 Dec 2022 13:59:06 GMT</CreateTime>
            <LastModifyTime>Thu, 22 Dec 2022 13:59:06 GMT</LastModifyTime>
          </Style>
        </StyleList>