OSS图片 数据处理持久化 JAVA实现

2021-06-22 20:08

阅读:598

标签:catch   enc   target   1.0   mes   ota   lock   hang   方式   

七牛及阿里云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]:


InvalidArgument
operation not support post: x-oss-process=image/rotate
5BA230AC8236378C162A25E5
zzzz.oss-cn-shanghai.aliyuncs.com

 

  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]:


NoSuchKey
The specified key does not exist.
5BA231E84031CABEAB41A444
imx.oss-cn-shanghai.aliyuncs.com
Key

>test1536995822372.jpg?x-oss-process=image/rotate,90

OSS图片 数据处理持久化 JAVA实现

标签:catch   enc   target   1.0   mes   ota   lock   hang   方式   

原文地址:https://www.cnblogs.com/nanahome/p/9676557.html


评论


亲,登录后才可以留言!