use of com.qcloud.cos.transfer.MultipleImageAuditingImpl in project cos-java-sdk-v5 by tencentyun.
the class ImageAuditingDemo method batchPostImageAuditing.
/**
* 批量发送图片审核任务 使用sdk并发发送
*/
public static void batchPostImageAuditing(COSClient client) throws InterruptedException {
List<ImageAuditingRequest> requestList = new ArrayList<>();
ImageAuditingRequest request = new ImageAuditingRequest();
request.setBucketName("demo-123456789");
request.setObjectKey("1.png");
request.setDetectType("all");
requestList.add(request);
request = new ImageAuditingRequest();
request.setBucketName("demo-123456789");
request.setObjectKey("1.jpg");
request.setDetectType("all");
requestList.add(request);
// 传入一个threadpool, 若不传入线程池, 默认TransferManager中会生成一个单线程的线程池。
ExecutorService threadPool = Executors.newFixedThreadPool(4);
TransferManager transferManager = new TransferManager(client, threadPool);
MultipleImageAuditingImpl multipleImageAuditing = transferManager.batchPostImageAuditing(requestList);
multipleImageAuditing.waitForCompletion();
List<ImageAuditingImpl> imageAuditingList = multipleImageAuditing.getImageAuditingList();
for (ImageAuditingImpl imageAuditing : imageAuditingList) {
System.out.println(imageAuditing.getState());
System.out.println(imageAuditing.getResponse());
System.out.println(imageAuditing.getErrMsg());
}
transferManager.shutdownNow();
client.shutdown();
}
Aggregations