简介
本文档提供关于提交多任务处理相关的 API 概览以及 SDK 示例代码。
API | 操作描述 |
提交多个任务 |
SDK API 参考
提交多任务处理
功能说明
提交多个任务
注意:
COS iOS SDK 版本需要大于等于 v6.2.5。
示例代码
Objective-C
QCloudCreateMediaJobRequest *request = [QCloudCreateMediaJobRequest new];// 存储桶名称,格式为 BucketName-APPIDrequest.bucket = @"test-123456789";// 文件所在地域request.regionName = @"ap-chongqing";request.input = @{@"Input": @{@"Object": @"input/demo.mp4"},@"Operation": @[// 任务一:视频转动图@{@"Tag": @"Animation",@"TemplateId": @"t1f16e1dfbdc994105b31292d45710642a",@"Output": @{@"Region": @"ap-chongqing",@"Bucket": @"test-123456789",@"Object": @"output/animation.gif"},@"UserData": @"This is my Animation job.",@"JobLevel": @0},// 任务二:音视频转码@{@"Tag": @"Transcode",@"TemplateId": @"t1995d523e42df4c5e858f244b4174360c",@"Output": @{@"Region": @"ap-chongqing",@"Bucket": @"test-123456789",@"Object": @"output/transcode.mp4"},@"UserData": @"This is my Trancode job.", // 原文拼写,透传字段保持原样@"JobLevel": @0},// 任务三:智能封面@{@"Tag": @"SmartCover",@"SmartCover": @{@"Format": @"jpg",@"Width": @1280,@"Height": @960,@"Count": @5,@"DeleteDuplicates": @"true"},@"Output": @{@"Region": @"ap-chongqing",@"Bucket": @"test-123456789",@"Object": @"output/smartcover-${Number}.jpg"},@"UserData": @"This is my SmartCover job.",@"JobLevel": @0}],@"CallBack": @"http://callback.demo.com",@"CallBackFormat": @"JSON"};[request setFinishBlock:^(QCloudCreateMediaJobResponse * _Nullable result, NSError * _Nullable error) {// 多任务返回多个 JobsDetail,数组顺序与提交的任务顺序对应// result 详细字段请查看 API 文档或者 SDK 源码NSLog(@"jobs: %@", result.JobsDetail);}];[[QCloudCOSXMLService defaultCOSXML] CreateMediaJob:request];
说明:
Swift
let request = QCloudCreateMediaJobRequest()request.bucket = "test-123456789"request.regionName = "ap-chongqing"request.input = ["Input": ["Object": "input/demo.mp4"],"Operation": [// Animation["Tag": "Animation","TemplateId": "t1f16e1dfbdc994105b31292d45710642a","Output": ["Region": "ap-chongqing", "Bucket": "test-123456789", "Object": "output/animation.gif"],"UserData": "This is my Animation job.","JobLevel": 0],// Transcode["Tag": "Transcode","TemplateId": "t1995d523e42df4c5e858f244b4174360c","Output": ["Region": "ap-chongqing", "Bucket": "test-123456789", "Object": "output/transcode.mp4"],"UserData": "This is my Trancode job.","JobLevel": 0],// SmartCover["Tag": "SmartCover","SmartCover": ["Format": "jpg", "Width": 1280, "Height": 960, "Count": 5,"DeleteDuplicates": "true"],"Output": ["Region": "ap-chongqing", "Bucket": "test-123456789", "Object": "output/smartcover-${Number}.jpg"],"UserData": "This is my SmartCover job.","JobLevel": 0]],"CallBack": "http://callback.demo.com","CallBackFormat": "JSON"]request.setFinish { result, error in// result 详细字段请查看 API 文档或者 SDK 源码if let error = error {print("create media job failed: \\(error)")return}print(result?.jobsDetail ?? []) // 三个任务 → 三条 JobsDetail}QCloudCOSXMLService.defaultCOSXML().createMediaJob(request)
说明: