-
Notifications
You must be signed in to change notification settings - Fork 142
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #119 from 563750789/master
更新万象接口
- Loading branch information
Showing
22 changed files
with
798 additions
and
100 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
package com.qcloud.cos.demo.ci; | ||
|
||
import com.qcloud.cos.COSClient; | ||
import com.qcloud.cos.model.ciModel.image.ImageStyleRequest; | ||
import com.qcloud.cos.model.ciModel.image.ImageStyleResponse; | ||
import com.qcloud.cos.model.ciModel.image.StyleRule; | ||
|
||
import java.util.List; | ||
|
||
|
||
/** | ||
* 图片样式接口 demo | ||
* 接口详情见 https://cloud.tencent.com/document/product/460/30118 | ||
*/ | ||
public class ImageStyleDemo { | ||
public static void main(String[] args) throws Exception { | ||
COSClient cosClient = ClientUtils.getTestClient(); | ||
// 小于5GB文件用简单上传 | ||
addImageStyle(cosClient); | ||
cosClient.shutdown(); | ||
} | ||
|
||
/** | ||
* 添加图片处理样式 | ||
* https://cloud.tencent.com/document/product/460/53491 | ||
*/ | ||
public static void addImageStyle(COSClient cosClient) { | ||
//1.创建二维码生成请求对象 | ||
ImageStyleRequest request = new ImageStyleRequest(); | ||
//2.添加请求参数 参数详情请见api接口文档 | ||
request.setBucketName("examplebucket-1250000000"); | ||
request.setStyleName("DemoStyle"); | ||
//设置样式规则,demo此处处理规则含义为:缩放图片宽高为原图50% | ||
request.setStyleBody("imageMogr2/thumbnail/!50p"); | ||
Boolean response = cosClient.addImageStyle(request); | ||
} | ||
|
||
/** | ||
* 查询图片处理样式 | ||
* https://cloud.tencent.com/document/product/460/30117 | ||
*/ | ||
public static void getImageStyle(COSClient cosClient) { | ||
//1.创建二维码生成请求对象 | ||
ImageStyleRequest request = new ImageStyleRequest(); | ||
//2.添加请求参数 参数详情请见api接口文档 | ||
request.setBucketName("examplebucket-1250000000"); | ||
request.setStyleName("DemoStyle"); | ||
ImageStyleResponse response = cosClient.getImageStyle(request); | ||
List<StyleRule> styleRule = response.getStyleRule(); | ||
for (StyleRule rule : styleRule) { | ||
System.out.println(rule.getStyleName()); | ||
System.out.println(rule.getStyleBody()); | ||
} | ||
} | ||
|
||
/** | ||
* 查询图片处理样式 | ||
* https://cloud.tencent.com/document/product/460/30117 | ||
*/ | ||
public static void deleteImageStyle(COSClient cosClient) { | ||
//1.创建二维码生成请求对象 | ||
ImageStyleRequest request = new ImageStyleRequest(); | ||
//2.添加请求参数 参数详情请见api接口文档 | ||
request.setBucketName("examplebucket-1250000000"); | ||
request.setStyleName("DemoStyle"); | ||
//设置样式规则,demo此处处理规则含义为:缩放图片宽高为原图50% | ||
request.setStyleBody("imageMogr2/thumbnail/!50p"); | ||
Boolean response = cosClient.deleteImageStyle(request); | ||
} | ||
|
||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
45 changes: 45 additions & 0 deletions
45
src/main/java/com/qcloud/cos/endpoint/CIPicRegionEndpointBuilder.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
/* | ||
* Copyright 2010-2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"). | ||
* You may not use this file except in compliance with the License. | ||
* A copy of the License is located at | ||
* | ||
* http://aws.amazon.com/apache2.0 | ||
* | ||
* or in the "license" file accompanying this file. This file is distributed | ||
* on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either | ||
* express or implied. See the License for the specific language governing | ||
* permissions and limitations under the License. | ||
* According to cos feature, we modify some class,comment, field name, etc. | ||
*/ | ||
|
||
|
||
package com.qcloud.cos.endpoint; | ||
|
||
import com.qcloud.cos.internal.BucketNameUtils; | ||
import com.qcloud.cos.region.Region; | ||
|
||
public class CIPicRegionEndpointBuilder implements EndpointBuilder { | ||
private Region region; | ||
|
||
public CIPicRegionEndpointBuilder(Region region) { | ||
super(); | ||
this.region = region; | ||
} | ||
|
||
@Override | ||
public String buildGeneralApiEndpoint(String bucketName) { | ||
if (this.region == null) { | ||
throw new IllegalArgumentException("region is null"); | ||
} | ||
BucketNameUtils.validateBucketName(bucketName); | ||
return String.format("%s.pic.%s.myqcloud.com", bucketName, Region.formatCIRegion(this.region)); | ||
} | ||
|
||
@Override | ||
public String buildGetServiceApiEndpoint() { | ||
return "service.pic.myqcloud.com"; | ||
} | ||
} |
24 changes: 24 additions & 0 deletions
24
src/main/java/com/qcloud/cos/internal/CIPicServiceRequest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
/* | ||
* Copyright 2020 腾讯云, Inc. or its affiliates. All Rights Reserved. | ||
* | ||
* Copyright 2010-2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"). | ||
* You may not use this file except in compliance with the License. | ||
* A copy of the License is located at | ||
* | ||
* http://aws.amazon.com/apache2.0 | ||
* | ||
* or in the "license" file accompanying this file. This file is distributed | ||
* on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either | ||
* express or implied. See the License for the specific language governing | ||
* permissions and limitations under the License. | ||
* According to ci feature, we modify some class,comment, field name, etc. | ||
*/ | ||
|
||
package com.qcloud.cos.internal; | ||
|
||
public class CIPicServiceRequest extends CIServiceRequest { | ||
|
||
} |
Oops, something went wrong.