use of com.qcloud.cos.model.ciModel.auditing.ImageAuditingResponse in project cos-java-sdk-v5 by tencentyun.
the class ImageAuditingCallable method call.
/**
* This method must return a non-null object, or else the existing implementation in
* {@link AbstractTransfer#waitForCompletion()} would block forever.
*
* @return the ImageAuditingResponse
*/
@Override
public ImageAuditingResponse call() throws Exception {
ImageAuditingResponse imageAuditingResponse = null;
try {
latch.await();
imageAuditing.setState(TransferState.InProgress);
imageAuditingResponse = cos.imageAuditing(req);
if (imageAuditingResponse == null) {
imageAuditing.setState(TransferState.Canceled);
imageAuditing.setMonitor(new ImageAuditingMonitor(imageAuditing, null));
} else {
imageAuditing.setResponse(imageAuditingResponse);
imageAuditing.setState(TransferState.Completed);
}
return imageAuditingResponse;
} catch (Throwable t) {
if (imageAuditing.getState() != TransferState.Canceled) {
imageAuditing.setState(TransferState.Failed);
}
imageAuditing.setErrMsg(t.getMessage());
return new ImageAuditingResponse();
}
}
use of com.qcloud.cos.model.ciModel.auditing.ImageAuditingResponse in project cos-java-sdk-v5 by tencentyun.
the class ImageAuditingDemo method imageAuditing.
/**
* createImageAuditingJob 接口用于创建图片审核任务。(发送单个任务 推荐)
*
* @param client
*/
public static void imageAuditing(COSClient client) {
// 1.创建任务请求对象
ImageAuditingRequest request = new ImageAuditingRequest();
// 2.添加请求参数 参数详情请见api接口文档
// 2.1设置请求bucket
request.setBucketName("demo-123456789");
// 2.2设置审核类型
request.setDetectType("porn");
// 2.3设置bucket中的图片位置
request.setObjectKey("1.jpg");
// 2.4设置图片压缩参数 0(不压缩),1(压缩)默认为零
request.setLargeImageDetect("1");
// 3.调用接口,获取任务响应对象
ImageAuditingResponse response = client.imageAuditing(request);
// 4调用工具类,获取各审核类型详情集合 (也可自行根据业务解析)
List<AuditingInfo> imageInfoList = AuditingResultUtil.getImageInfoList(response);
System.out.println(response);
}
Aggregations