Search in sources :

Example 1 with BatchImageAuditingInputObject

use of com.qcloud.cos.model.ciModel.auditing.BatchImageAuditingInputObject in project cos-java-sdk-v5 by tencentyun.

the class RequestXmlFactory method convertToXmlByteArray.

public static byte[] convertToXmlByteArray(BatchImageAuditingRequest request) {
    XmlWriter xml = new XmlWriter();
    xml.start("Request");
    List<BatchImageAuditingInputObject> inputList = request.getInputList();
    for (BatchImageAuditingInputObject inputObject : inputList) {
        xml.start("Input");
        addIfNotNull(xml, "Url", inputObject.getUrl());
        addIfNotNull(xml, "Object", inputObject.getObject());
        addIfNotNull(xml, "DataId", inputObject.getDataId());
        addIfNotNull(xml, "MaxFrames", inputObject.getMaxFrames());
        addIfNotNull(xml, "Interval", inputObject.getInterval());
        xml.end();
    }
    Conf conf = request.getConf();
    xml.start("Conf");
    String detectType = conf.getDetectType();
    if ("all".equalsIgnoreCase(detectType)) {
        detectType = "Porn,Terrorism,Politics,Ads";
    }
    addIfNotNull(xml, "DetectType", detectType);
    addIfNotNull(xml, "Callback", conf.getCallback());
    addIfNotNull(xml, "BizType", conf.getBizType());
    xml.end();
    xml.end();
    return xml.getBytes();
}
Also used : BatchImageAuditingInputObject(com.qcloud.cos.model.ciModel.auditing.BatchImageAuditingInputObject) Conf(com.qcloud.cos.model.ciModel.auditing.Conf)

Example 2 with BatchImageAuditingInputObject

use of com.qcloud.cos.model.ciModel.auditing.BatchImageAuditingInputObject in project cos-java-sdk-v5 by tencentyun.

the class ImageAuditingDemo method batchImageAuditing.

/**
 * batchImageAuditing 接口批量创建图片审核任务。 (推荐)
 *
 * @param client
 */
public static void batchImageAuditing(COSClient client) {
    // 1.创建任务请求对象
    BatchImageAuditingRequest request = new BatchImageAuditingRequest();
    // 2.添加请求参数 参数详情请见api接口文档
    // 2.1设置请求bucket
    request.setBucketName("demo-123456789");
    // 2.2添加请求内容
    List<BatchImageAuditingInputObject> inputList = request.getInputList();
    BatchImageAuditingInputObject input = new BatchImageAuditingInputObject();
    input.setObject("1.jpg");
    input.setDataId("DataId");
    inputList.add(input);
    input = new BatchImageAuditingInputObject();
    input.setUrl("https://demo-123456789.cos.ap-chongqing.myqcloud.com/1.png");
    input.setDataId("DataId");
    inputList.add(input);
    // 2.2设置审核类型
    request.getConf().setDetectType("all");
    // 3.调用接口,获取任务响应对象
    BatchImageAuditingResponse response = client.batchImageAuditing(request);
    List<BatchImageJobDetail> jobList = response.getJobList();
    for (BatchImageJobDetail batchImageJobDetail : jobList) {
        List<AuditingInfo> imageInfoList = AuditingResultUtil.getBatchImageInfoList(batchImageJobDetail);
        System.out.println(imageInfoList);
    }
}
Also used : BatchImageAuditingInputObject(com.qcloud.cos.model.ciModel.auditing.BatchImageAuditingInputObject) BatchImageAuditingRequest(com.qcloud.cos.model.ciModel.auditing.BatchImageAuditingRequest) BatchImageAuditingResponse(com.qcloud.cos.model.ciModel.auditing.BatchImageAuditingResponse) BatchImageJobDetail(com.qcloud.cos.model.ciModel.auditing.BatchImageJobDetail) AuditingInfo(com.qcloud.cos.model.ciModel.auditing.AuditingInfo)

Aggregations

BatchImageAuditingInputObject (com.qcloud.cos.model.ciModel.auditing.BatchImageAuditingInputObject)2 AuditingInfo (com.qcloud.cos.model.ciModel.auditing.AuditingInfo)1 BatchImageAuditingRequest (com.qcloud.cos.model.ciModel.auditing.BatchImageAuditingRequest)1 BatchImageAuditingResponse (com.qcloud.cos.model.ciModel.auditing.BatchImageAuditingResponse)1 BatchImageJobDetail (com.qcloud.cos.model.ciModel.auditing.BatchImageJobDetail)1 Conf (com.qcloud.cos.model.ciModel.auditing.Conf)1