Skip to content

Commit 7139304

Browse files
Merge pull request #139 from wqingzhang/feature_wqingzhang_07b4400f
Feature wqingzhang 07b4400f
2 parents 048ba86 + 8a6c3fa commit 7139304

File tree

12 files changed

+535
-19
lines changed

12 files changed

+535
-19
lines changed

demo/cos_demo.cpp

Lines changed: 74 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -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
25672634
void 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");

include/cos_api.h

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -883,6 +883,15 @@ class CosAPI {
883883
// https://cloud.tencent.com/document/product/436/55672
884884
CosResult GetMediaInfo(const GetMediaInfoReq& req, GetMediaInfoResp* resp);
885885

886+
/* 异步任务接口 */
887+
/** 创建异步任务 **/
888+
CosResult CreateDataProcessJobs(const CreateDataProcessJobsReq& req,
889+
CreateDataProcessJobsResp* resp);
890+
891+
/** 查询异步任务 **/
892+
CosResult DescribeDataProcessJob(const DescribeDataProcessJobReq& req,
893+
DescribeDataProcessJobResp* resp);
894+
886895
/* 内容审核接口 */
887896

888897
/** 图片审核 **/

include/op/base_op.h

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -52,16 +52,17 @@ class BaseOp {
5252
/// \brief 封装了cos Service/Bucket/Object 相关接口的通用操作,
5353
/// 包括签名计算、请求发送、返回内容解析等
5454
///
55-
/// \param host 目标主机, 以http://开头
56-
/// \param path http path
57-
/// \param req http请求
58-
/// \param req_body http request的body
59-
/// \param resp http返回
55+
/// \param host 目标主机, 以http://开头
56+
/// \param path http path
57+
/// \param req http请求
58+
/// \param req_body http request的body
59+
/// \param resp http返回
60+
/// \param is_ci_req 是否为万象域名请求
6061
///
6162
/// \return http调用情况(状态码等)
6263
CosResult NormalAction(const std::string& host, const std::string& path,
6364
const BaseReq& req, const std::string& req_body,
64-
bool check_body, BaseResp* resp);
65+
bool check_body, BaseResp* resp, bool is_ci_req = false);
6566

6667
/// \brief 封装了cos Service/Bucket/Object相关接口的通用操作,
6768
/// 包括签名计算、请求发送、返回内容解析等
@@ -73,13 +74,15 @@ class BaseOp {
7374
/// \param additional_params http请求需要所需的额外params
7475
/// \param req_body http request的body
7576
/// \param resp http返回
77+
/// \param is_ci_req 是否为万象域名请求
7678
///
7779
/// \return http调用情况(状态码等)
7880
CosResult NormalAction(
7981
const std::string& host, const std::string& path, const BaseReq& req,
8082
const std::map<std::string, std::string>& additional_headers,
8183
const std::map<std::string, std::string>& additional_params,
82-
const std::string& req_body, bool check_body, BaseResp* resp);
84+
const std::string& req_body, bool check_body, BaseResp* resp,
85+
bool is_ci_req = false);
8386

8487
/// \brief 下载文件并输出到流中
8588
///

include/op/bucket_op.h

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -481,6 +481,7 @@ class BucketOp : public BaseOp {
481481
/// \return 本次请求的调用情况(如状态码等)
482482
CosResult CreateMediaBucket(const CreateMediaBucketReq& req,
483483
CreateMediaBucketResp* resp);
484+
484485
/// \brief 获取媒体文件信息
485486
/// \brief https://cloud.tencent.com/document/product/436/55672
486487
/// \param req GetMediainfo请求
@@ -489,6 +490,22 @@ class BucketOp : public BaseOp {
489490
/// \return 本次请求的调用情况(如状态码等)
490491
CosResult GetMediainfo(const GetMediaInfoReq& req, GetMediaInfoResp* resp);
491492

493+
/// \brief 提交数据处理任务
494+
/// \brief https://cloud.tencent.com/document/product/436/83110
495+
/// \param req CreateFileProcessJobs请求
496+
/// \param resp CreateFileProcessJobs返回
497+
///
498+
/// \return 本次请求的调用情况(如状态码等)
499+
CosResult CreateDataProcessJobs(const CreateDataProcessJobsReq& req,
500+
CreateDataProcessJobsResp* resp);
501+
502+
/// \brief 提交数据处理任务
503+
/// \param req DescribeDataProcessJobs请求
504+
/// \param resp DescribeDataProcessJobs返回
505+
///
506+
/// \return 本次请求的调用情况(如状态码等)
507+
CosResult DescribeDataProcessJob(const DescribeDataProcessJobReq& req,
508+
DescribeDataProcessJobResp* resp);
492509
/// \brief 图片批量审核
493510
/// \brief https://cloud.tencent.com/document/product/436/63593
494511
/// \param req BatchImageAuditing请求

0 commit comments

Comments
 (0)