zoukankan      html  css  js  c++  java
  • OSS图片 数据处理持久化 JAVA实现

    七牛及阿里云OSS图片旋转问题

    上一篇文章我用了URL方式的图片旋转功能。但我需要的是一个持久化的结果。把旋转后的图片保存到OSS上,所以需要 数据持久化的操作。

    数据处理持久化

    ProcessObjectRequest 

    https://help.aliyun.com/document_detail/55811.html

     1         key=StringUtils.substringBefore(key, "?");
     2         key=StringUtils.remove(key, BizConstants.ALIYUN_IMAGE_SITE_URL);
     3         String rotate=number+"";
     4         String o=EncodeUtil.encodeString(key);
     5         String b=EncodeUtil.encodeString(BizConstants.IMAGE_OSS_BUCKET_NAME);
     6         String style = "image/rotate,%s|sys/saveas,o_%s,b_%s";
     7         style=String.format(style, rotate,o,b);
     8         logger.debug("style========>{}",style);
     9         ProcessObjectRequest request = new ProcessObjectRequest(BizConstants.IMAGE_OSS_BUCKET_NAME, key,style);
    10         try {
    11             ossClient.processObject(request);
    12             return Boolean.TRUE;
    13         } catch (Exception e) {
    14             e.printStackTrace();
    15             return Boolean.FALSE;
    16         }
    17     

     x-oss-process=image/rotate

    红色部分不需要写 style 中

    com.aliyun.oss.OSSException: operation not support post: x-oss-process=image/rotate
    [ErrorCode]: InvalidArgument
    [RequestId]: 5BA230AC8236378C162A25E5
    [HostId]: imgadrms.oss-cn-shanghai.aliyuncs.com
    [ResponseError]:
    <?xml version="1.0" encoding="UTF-8"?>
    <Error>
    <Code>InvalidArgument</Code>
    <Message>operation not support post: x-oss-process=image/rotate</Message>
    <RequestId>5BA230AC8236378C162A25E5</RequestId>
    <HostId>zzzz.oss-cn-shanghai.aliyuncs.com</HostId>
    </Error>

      Key错了。正确的KEY是 test1536995822372.jpg  不能带?以后部分

    com.aliyun.oss.OSSException: The specified key does not exist.
    [ErrorCode]: NoSuchKey
    [RequestId]: 5BA231E84031CABEAB41A444
    [HostId]: imgadrms.oss-cn-shanghai.aliyuncs.com
    [ResponseError]:
    <?xml version="1.0" encoding="UTF-8"?>
    <Error>
    <Code>NoSuchKey</Code>
    <Message>The specified key does not exist.</Message>
    <RequestId>5BA231E84031CABEAB41A444</RequestId>
    <HostId>imx.oss-cn-shanghai.aliyuncs.com</HostId>
    <Key>test1536995822372.jpg?x-oss-process=image/rotate,90</Key>
    </Error>

  • 相关阅读:
    linux ftp启用和停用及vsftpd安装 ssh 启用和停用命令及ssh的安装
    linux 网络命令
    printf的使用
    Shell echo命令
    shell脚本之文件操作
    shell脚本之字符串运算的使用
    linux的计划任务操作
    系统操作有关的命令
    shell脚本之 operater.sh 算术运算符;比较运算符;布尔运算符;逻辑与或非运算符;字符串运算符的使用
    shell脚本的参数传递使用
  • 原文地址:https://www.cnblogs.com/nanahome/p/9676557.html
Copyright © 2011-2022 走看看