All Products
Search
Document Center

Object Storage Service:style

Last Updated:Aug 19, 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.

  • For ossutil 1.6.16 and later, you can directly use ossutil as the binary name in the command line. You do not need to update the binary name based on the operating system. For ossutil earlier than 1.6.16, you need to update the binary name based on the operating system. For more information, see ossutil command reference.

  • Only ossutil 1.7.16 and later support the style command.

Configure image styles

  • Command syntax

    ossutil style --method put oss://bucketname/ stylename local_xml_file

    The following table describes the preceding parameters.

    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. Configure an image style named examplestyle for a bucket named examplebucket.

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

      Sample output:

      0.299514(s) elapsed

Query image styles

  • Command syntax

    ossutil style --method get oss://bucketname/ stylename local_xml_file

    The following table describes the preceding parameters.

    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

    • Run the following command to query an image style named examplestyle configured for a bucket named examplebucket and list the query results:

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

      Sample output:

      <?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
    • Run the following command to query an image style named examplestyle configured for a bucket named examplebucket and store the image style in a local file:

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

      Sample output:

      • The following result is displayed:

        0.214483(s) elapsed
      • The local.xml 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

    ossutil style --method delete oss://bucketname/ stylename 

    The following table describes the preceding parameters.

    Parameter

    Description

    bucketname

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

    stylename

    The name of the image style.

  • Examples

    Run the following command to delete an image style named examplestyle configured for 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

    ossutil style --method list oss://bucketname/ local_xml_file

    The following table describes the preceding parameters.

    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

    • Run the following command to list the image styles configured for a bucket named examplebucket and display the list results:

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

      Sample output:

      <?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
    • Run the following command to list the image styles configured for a bucket named examplebucket and store the image styles in a local file:

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

      Sample output:

      • The following result is displayed:

        2.655387(s) elapsed
      • The local.xml 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>