use of com.qcloud.cos.model.ciModel.queue.DocQueueRequest in project cos-java-sdk-v5 by tencentyun.
the class DocJobDemo method processDocJob.
/**
* 文档预览完整调用demo
*/
public static void processDocJob(COSClient client) throws InterruptedException {
String bucketName = "demo-123456789";
// 1.获取队列id,需要先开启文档预览功能。
DocQueueRequest queueRequest = new DocQueueRequest();
queueRequest.setBucketName(bucketName);
DocListQueueResponse response = client.describeDocProcessQueues(queueRequest);
List<MediaQueueObject> queueList = response.getQueueList();
String queueId = "";
if (queueList.size() != 0) {
MediaQueueObject mediaQueueObject = queueList.get(0);
queueId = mediaQueueObject.getQueueId();
} else {
System.out.println("获取队列失败");
return;
}
// 2.发送文档预览任务
// 2.1添加请求参数 参数详情请见api接口文档
DocJobRequest request = new DocJobRequest();
request.setBucketName(bucketName);
DocJobObject docJobObject = request.getDocJobObject();
docJobObject.setTag("DocProcess");
docJobObject.getInput().setObject("1.pdf");
docJobObject.setQueueId(queueId);
DocProcessObject docProcessObject = docJobObject.getOperation().getDocProcessObject();
docProcessObject.setQuality("100");
docProcessObject.setZoom("100");
docProcessObject.setEndPage("-1");
docProcessObject.setTgtType("jpg");
MediaOutputObject output = docJobObject.getOperation().getOutput();
output.setRegion(client.getClientConfig().getRegion().getRegionName());
output.setBucket(bucketName);
output.setObject("demo/pic-${Number}.jpg");
// 2.2发送预览请求
DocJobResponse docProcessJobs = client.createDocProcessJobs(request);
// 3.轮询查询任务结果(也可以配置队列的回调url,使用回调接口获取任务结果)
DocJobRequest docJobRequest = new DocJobRequest();
docJobRequest.setBucketName(bucketName);
String jobId = docProcessJobs.getJobsDetail().getJobId();
docJobRequest.setJobId(jobId);
while (true) {
DocJobResponse docJobResponse = client.describeDocProcessJob(docJobRequest);
String state = docJobResponse.getJobsDetail().getState();
// 判断任务状态
if ("Success".equalsIgnoreCase(state) || "Failed".equalsIgnoreCase(state)) {
// 处理业务逻辑
System.out.println(docJobResponse);
break;
} else {
Thread.sleep(500);
}
}
}
use of com.qcloud.cos.model.ciModel.queue.DocQueueRequest in project cos-java-sdk-v5 by tencentyun.
the class DocQueueDemo method updateDocProcessQueue.
/**
* UpdateDocProcessQueue 接口用于更新文档预览队列
* @param client
*/
public static void updateDocProcessQueue(COSClient client) {
// 1.创建任务请求对象
DocQueueRequest request = new DocQueueRequest();
// 2.添加请求参数 参数详情请见api接口文档
request.setBucketName("examplebucket-1250000000");
request.setQueueId("pc02270c617ae4b6d9b0a52cb1cf****");
request.getNotifyConfig().setUrl("http://cloud.tencent.com");
request.getNotifyConfig().setState("On");
request.getNotifyConfig().setEvent("TransCodingFinish");
request.getNotifyConfig().setType("Url");
request.setState("Active");
request.setName("mark");
// 3.调用接口,获取任务响应对象
boolean result = client.updateDocProcessQueue(request);
System.out.println(result);
}
use of com.qcloud.cos.model.ciModel.queue.DocQueueRequest in project cos-java-sdk-v5 by tencentyun.
the class DocQueueDemo method describeDocProcessQueues.
/**
* DescribeDocProcessQueues 接口用于查询文档预览队列。
* @param client
*/
public static void describeDocProcessQueues(COSClient client) {
// 1.创建任务请求对象
DocQueueRequest request = new DocQueueRequest();
// 2.添加请求参数 参数详情请见api接口文档
request.setBucketName("examplebucket-1250000000");
// 3.调用接口,获取任务响应对象
DocListQueueResponse response = client.describeDocProcessQueues(request);
System.out.println(response);
}
Aggregations