BK
This commit is contained in:
@@ -84,6 +84,58 @@ std::string module::tencent_cos::upfile(const std::string& appid,const std::stri
|
||||
cos_pool_destroy(p);
|
||||
return result;
|
||||
}
|
||||
std::string module::tencent_cos::del(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)
|
||||
{
|
||||
|
||||
int enable_checkpoint = COS_FALSE; // 是否开启断点续传
|
||||
cos_pool_t* p = NULL;
|
||||
cos_string_t bucket;
|
||||
cos_string_t object;
|
||||
cos_string_t filename;
|
||||
cos_status_t* s = NULL;
|
||||
cos_table_t* headers = NULL;
|
||||
cos_table_t* resp_headers = NULL;
|
||||
cos_request_options_t* options = NULL;
|
||||
cos_resumable_clt_params_t* clt_params;
|
||||
cos_pool_create(&p, NULL);
|
||||
|
||||
|
||||
|
||||
options = cos_request_options_create(p);
|
||||
|
||||
options->config = cos_config_create(options->pool);
|
||||
|
||||
cos_str_set(&options->config->endpoint, endpoint.c_str());
|
||||
cos_str_set(&options->config->access_key_id, access_key_id.c_str());
|
||||
cos_str_set(&options->config->access_key_secret, access_key_secret.c_str());
|
||||
cos_str_set(&options->config->appid, appid.c_str());
|
||||
// cos_str_set(&config->sts_token, token); // 使用临时密钥时的 token
|
||||
options->config->is_cname = COS_FALSE; // 是否使用自定义域名
|
||||
|
||||
|
||||
options->ctl = cos_http_controller_create(options->pool, 0);
|
||||
|
||||
|
||||
headers = cos_table_make(p, 0);
|
||||
cos_str_set(&bucket, bucket_name.c_str());
|
||||
cos_str_set(&object, object_name.c_str());
|
||||
|
||||
|
||||
|
||||
s = cos_delete_object(options, &bucket, &object, &resp_headers);
|
||||
|
||||
|
||||
std::string result = "";
|
||||
if (cos_status_is_ok(s)) {
|
||||
result = "";
|
||||
}
|
||||
else
|
||||
{
|
||||
result = "code:" + std::to_string(s->code)+", error_code:"+s->error_code+", error_msg:"+s->error_msg;
|
||||
}
|
||||
cos_pool_destroy(p);
|
||||
return result;
|
||||
}
|
||||
|
||||
void module::tencent_cos::regist(sol::state* lua)
|
||||
{
|
||||
|
||||
@@ -7,7 +7,7 @@ namespace module
|
||||
tencent_cos();
|
||||
~tencent_cos() override;
|
||||
std::string 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& filename);
|
||||
|
||||
std::string del(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);
|
||||
static void regist(sol::state* lua);
|
||||
private:
|
||||
// 通过 imodule 继承
|
||||
|
||||
Reference in New Issue
Block a user