@@ -2562,6 +2562,73 @@ void GetMediaInfo(qcloud_cos::CosAPI& cos, const std::string& bucket_name,
25622562 << std::endl;
25632563}
25642564
2565+ // 创建文件解压缩任务
2566+ void CreateFileUncompressJobs (qcloud_cos::CosAPI& cos,
2567+ const std::string& bucket_name) {
2568+ CreateDataProcessJobsReq req (bucket_name);
2569+ CreateDataProcessJobsResp resp;
2570+
2571+ JobsOptions opt;
2572+ opt.input .bucket = bucket_name;
2573+ opt.input .region = " ap-chongqing" ;
2574+ opt.input .object = " test.zip" ;
2575+ opt.tag = " FileUncompress" ;
2576+
2577+ // 文件解压参数
2578+ // 指定解压后输出文件的前缀,不填则默认保存在存储桶根路径,非必选
2579+ opt.operation .file_uncompress_config .prefix = " output/" ;
2580+ // 指定解压后的文件路径是否需要替换前缀,可选值如下
2581+ // 0:不添加额外的前缀,解压缩将保存在Prefix指定的路径下(不会保留压缩包的名称,仅将压缩包内的文件保存至指定的路径)
2582+ // 1:以压缩包本身的名称作为前缀,解压缩将保存在Prefix指定的路径下
2583+ // 2:以压缩包完整路径作为前缀,此时如果不指定Prefix,就是解压到压缩包所在的当前路径(包含压缩包本身名称)
2584+ // 非必选参数,默认 0
2585+ opt.operation .file_uncompress_config .prefix_replaced = " 1" ;
2586+ // 解压密钥,传入时需先经过 base64 编码,非必选
2587+ // opt.operation.file_uncompress_config.un_compress_key = "MTIzNDU2Nzg5MA==";
2588+
2589+ opt.operation .output .bucket = bucket_name;
2590+ opt.operation .output .region = " ap-chongqing" ;
2591+ req.setOperation (opt);
2592+
2593+ CosResult result = cos.CreateDataProcessJobs (req, &resp);
2594+ if (result.IsSucc ()) {
2595+ std::cout << " CreateFileProcessJobs Succ." << std::endl;
2596+ } else {
2597+ std::cout << " CreateFileProcessJobs Fail, ErrorMsg: "
2598+ << result.GetErrorMsg () << std::endl;
2599+ }
2600+ std::cout
2601+ << " ===================CreateFileProcessJobs============================="
2602+ << std::endl;
2603+ PrintResult (result, resp);
2604+ std::cout << " ========================================================"
2605+ << std::endl;
2606+ }
2607+
2608+ // 查询文件解压缩任务
2609+ void DescribeFileUncompressJobs (qcloud_cos::CosAPI& cos,
2610+ const std::string& bucket_name) {
2611+ DescribeDataProcessJobReq req (bucket_name);
2612+ DescribeDataProcessJobResp resp;
2613+
2614+ // 任务ID
2615+ req.SetJobId (" XXXXXXXXXXXXXXXXXXXXXXXXXXXXX" );
2616+
2617+ CosResult result = cos.DescribeDataProcessJob (req, &resp);
2618+ if (result.IsSucc ()) {
2619+ std::cout << " DescribeDataProcessJob Succ." << std::endl;
2620+ } else {
2621+ std::cout << " DescribeDataProcessJob Fail, ErrorMsg: "
2622+ << result.GetErrorMsg () << std::endl;
2623+ }
2624+ std::cout
2625+ << " ===================DescribeDataProcessJob============================="
2626+ << std::endl;
2627+ PrintResult (result, resp);
2628+ std::cout << " ========================================================"
2629+ << std::endl;
2630+ }
2631+
25652632// 图片同步审核
25662633// https://cloud.tencent.com/document/product/436/45434
25672634void GetImageAuditing (qcloud_cos::CosAPI& cos, const std::string& bucket_name,
@@ -3044,7 +3111,7 @@ int main(int argc, char** argv) {
30443111 config.SetLogCallback (&TestLogCallback);
30453112 qcloud_cos::CosAPI cos (config);
30463113 std::string bucket_name =
3047- " test-12345678 " ; // 替换为用户的存储桶名,由bucketname-appid
3114+ " test-123456 " ; // 替换为用户的存储桶名,由bucketname-appid
30483115 // /组成,appid必须填入,可以在COS控制台查看存储桶名称。
30493116 // / https://console.cloud.tencent.com/cos5/bucket
30503117
@@ -3446,6 +3513,12 @@ int main(int argc, char** argv) {
34463513 // GetMediaInfo(cos, bucket_name, "1920_1080.mp4");
34473514 // }
34483515
3516+ // 文件处理接口
3517+ {
3518+ // CreateFileUncompressJobs(cos, bucket_name);
3519+ // DescribeFileUncompressJobs(cos, bucket_name);
3520+ }
3521+
34493522 // 图片审核
34503523 // {
34513524 // GetImageAuditing(cos, bucket_name, "data/audit/gif/test.gif");
0 commit comments