From 6e72d681668b133a2c359a22df5faebaa3557f21 Mon Sep 17 00:00:00 2001 From: 1585346868 <1585346868@qq.com> Date: Tue, 30 Dec 2025 12:04:04 +0800 Subject: [PATCH] =?UTF-8?q?=E6=9B=B4=E6=96=B0=20src/tencent=5Fcos.cpp?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/tencent_cos.cpp | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/src/tencent_cos.cpp b/src/tencent_cos.cpp index 403e311..3150ca7 100644 --- a/src/tencent_cos.cpp +++ b/src/tencent_cos.cpp @@ -3,6 +3,7 @@ #include "cos_api.h" #include "cos_http_io.h" #include "cos_log.h" +static int inited = 0; extern "C" { #ifdef _WIN32 DLL_EXPORT @@ -17,14 +18,18 @@ extern "C" { module::tencent_cos::tencent_cos() { - if (cos_http_io_initialize(NULL, 0) != COSE_OK) { - printf("COS HTTP INIT FAILED"); + if(inited == 0){ + if (cos_http_io_initialize(NULL, 0) != COSE_OK) { + printf("COS HTTP INIT FAILED"); + return; + } + inited = 1; } } module::tencent_cos::~tencent_cos() { - cos_http_io_deinitialize(); + // cos_http_io_deinitialize(); } std::string module::tencent_cos::upfile(const std::string& appid,const std::string& endpoint,const std::string& access_key_id,const std::string& access_key_secret,const std::string& bucket_name,const std::string& object_name,const std::string& filepath)