From c991e099d082bbdc5169ed2e2e764e164b8e6bd2 Mon Sep 17 00:00:00 2001 From: huberyxxiao Date: Wed, 13 Nov 2024 18:36:33 +0800 Subject: [PATCH] demo fix --- demo/object_op_demo/multi_put_object_demo.cpp | 20 +++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/demo/object_op_demo/multi_put_object_demo.cpp b/demo/object_op_demo/multi_put_object_demo.cpp index b99fc19..1254b78 100644 --- a/demo/object_op_demo/multi_put_object_demo.cpp +++ b/demo/object_op_demo/multi_put_object_demo.cpp @@ -8,6 +8,7 @@ #include "cos_api.h" #include "cos_sys_config.h" #include "util/auth_tool.h" +// #include // 双向认证引用头 /** * 本样例演示了如何使用 COS C++ SDK 进行对象的高级上传 @@ -47,10 +48,27 @@ void PrintResult(const qcloud_cos::CosResult& result, const qcloud_cos::BaseResp qcloud_cos::CosAPI InitCosAPI() { qcloud_cos::CosConfig config(appid, tmp_secret_id, tmp_secret_key, region); config.SetTmpToken(tmp_token); // 推荐使用临时密钥初始化 CosAPI 对象, 如果您使用永久密钥初始化 CosAPI 对象,请注释 + // config.SetDestDomain("xxx.xxxx.com"); // 配置自定义域名 + // config.SetDomainSameToHost(true); // 配置自定义域名签名 qcloud_cos::CosAPI cos_tmp(config); return cos_tmp; } +/** + * 本方法为 SSL_CTX 的回调方法,用户可以在此方法中配置 SSL_CTX 信息 + */ +// int SslCtxCallback(void *ssl_ctx, void *data) { +// std::cout << "ssl_ctx: " << ssl_ctx << " data: " << data << std::endl; + +// SSL_CTX *ctx = (SSL_CTX *)ssl_ctx; +// std::cout << "ssl_ctx in" << std::endl; +// SSL_CTX_use_PrivateKey_file(ctx, "/data/cert/client.key", SSL_FILETYPE_PEM); +// SSL_CTX_use_certificate_chain_file(ctx, "/data/cert/client.crt"); +// std::cout << "ssl_ctx out" << std::endl; + +// return 0; +// } + /* * 该 Demo 示范如何使用高级上传接口进行对象上传 * 仅支持文件上传,不支持流式上传,封装了分块上传的各接口 @@ -64,6 +82,8 @@ void MultiUploadObjectDemo(qcloud_cos::CosAPI& cos) { CosSysConfig::SetUploadPartSize(10 * 1024 * 1024); // 上传分块大小 默认10M qcloud_cos::MultiPutObjectReq req(bucket_name, object_name, local_file); + // req.SetHttps(); // 设置 https 请求 + // req.SetSSLCtxCallback(SslCtxCallback, nullptr); //双向认证回调 qcloud_cos::MultiPutObjectResp resp; qcloud_cos::CosResult result = cos.MultiPutObject(req, &resp);