文档

style(设置图片样式)

更新时间:

style命令用于设置图片样式。

注意事项

  • 要设置样式,您必须具有oss:PutStyle权限;要获取样式,您必须具有oss:GetStyle权限;要删除样式,您必须具有oss:DeleteStyle权限。具体操作,请参见为RAM用户授权自定义的权限策略

  • 本文各命令行示例均基于Linux 64位系统,其他系统请将命令开头的./ossutil64替换成对应的Binary名称。更多信息,请参见命令行工具ossutil命令参考

  • 仅1.7.16及以上版本ossutil支持style命令。

设置样式

  • 命令格式

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

    参数说明如下:

    参数

    说明

    bucketname

    待设置样式的Bucket名称。

    stylename

    样式名称。

    local_xml_file

    用于设置样式的本地文件名称,例如config.xml

  • 使用示例

    1. 在本地XML文件中配置样式文件。

      <?xml version="1.0" encoding="UTF-8"?>
      <Style>
       <Content>image/resize,p_50</Content>
      </Style>
    2. 通过以下示例为examplebucket设置名为examplestyle的样式。

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

      输出结果如下:

      0.299514(s) elapsed

获取样式

  • 命令格式

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

    参数说明如下:

    参数

    说明

    bucketname

    待获取样式的Bucket名称。

    stylename

    样式名称。

    local_xml_file

    用于存放样式的本地文件名称,例如config.xml

  • 使用示例

    • 通过以下示例将examplebucket中名为examplestyle的样式获取到屏幕上。

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

      输出结果如下:

      <?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
    • 通过以下示例将examplebucket中名为examplestyle的样式获取到本地配置文件。

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

      输出结果如下:

      • 屏幕显示

        0.214483(s) elapsed
      • local.xml内容

        <?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>

删除样式

  • 命令格式

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

    参数说明如下:

    参数

    说明

    bucketname

    待删除样式的Bucket名称。

    stylename

    样式名称。

  • 使用示例

    通过以下示例删除examplebucket中名为examplestyle的样式。

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

    输入结果如下:

    0.184183(s) elapsed

列举样式

  • 命令格式

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

    参数说明如下:

    参数

    说明

    bucketname

    待列举样式的Bucket名称。

    local_xml_file

    用于存放样式的本地文件名称,例如config.xml

  • 使用示例

    • 通过以下示例将examplebucket中的样式列举到屏幕上。

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

      输出结果如下:

      <?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
    • 通过以下示例列举examplebucket中的样式并存放到本地配置文件。

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

      输出结果如下:

      • 屏幕显示

        2.655387(s) elapsed
      • local.xml内容

        <?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>
  • 本页导读 (1)
文档反馈