Search in sources :

Example 1 with ImageAuditingImpl

use of com.qcloud.cos.transfer.ImageAuditingImpl 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();
}
Also used : TransferManager(com.qcloud.cos.transfer.TransferManager) MultipleImageAuditingImpl(com.qcloud.cos.transfer.MultipleImageAuditingImpl) ArrayList(java.util.ArrayList) ExecutorService(java.util.concurrent.ExecutorService) BatchImageAuditingRequest(com.qcloud.cos.model.ciModel.auditing.BatchImageAuditingRequest) ImageAuditingRequest(com.qcloud.cos.model.ciModel.auditing.ImageAuditingRequest) ImageAuditingImpl(com.qcloud.cos.transfer.ImageAuditingImpl) MultipleImageAuditingImpl(com.qcloud.cos.transfer.MultipleImageAuditingImpl)

Aggregations

BatchImageAuditingRequest (com.qcloud.cos.model.ciModel.auditing.BatchImageAuditingRequest)1 ImageAuditingRequest (com.qcloud.cos.model.ciModel.auditing.ImageAuditingRequest)1 ImageAuditingImpl (com.qcloud.cos.transfer.ImageAuditingImpl)1 MultipleImageAuditingImpl (com.qcloud.cos.transfer.MultipleImageAuditingImpl)1 TransferManager (com.qcloud.cos.transfer.TransferManager)1 ArrayList (java.util.ArrayList)1 ExecutorService (java.util.concurrent.ExecutorService)1