API | 操作名 | 操作描述 |
设置存储桶复制 | 对已启用版本控制的存储桶配置存储桶复制规则 | |
查询存储桶复制 | 查询存储桶的存储桶复制配置信息 | |
删除存储桶复制 | 删除存储桶的存储桶复制配置信息 |
CosResult PutBucketReplication(const PutBucketReplicationReq& request, PutBucketReplicationResp* response);
qcloud_cos::CosConfig config("./config.json");qcloud_cos::CosAPI cos(config);std::string bucket_name = "examplebucket-1250000000";qcloud_cos::PutBucketReplicationReq req(bucket_name);qcloud_cos::PutBucketReplicationResp resp;req.SetRole("qcs::cam::uin/100000000001:uin/100000000001"); // 设置发起者身份qcloud_cos::ReplicationRule rule("", "qcs::cos:ap-guangzhou:uid/1250000000:destinationbucket-1250000000","", "", true); // 设置存储桶复制规则req.AddReplicationRule(rule);qcloud_cos::CosResult result = cos.PutBucketReplication(req, &resp);if (result.IsSucc()) {// 请求成功} else {// 请求失败,可以调用 CosResult 的成员函数输出错误信息,例如 requestID 等}
参数 | 参数描述 | 类型 | 是否必填 |
req | PutBucketReplication 操作的请求 | PutBucketReplicationReq | 是 |
resp | PutBucketReplication 操作的响应 | PutBucketReplicationResp | 是 |
void SetRole(const std::string& role)void AddReplicationRule(const ReplicationRule& rule)void SetReplicationRule(const std::vector<ReplicationRule>& rules)
struct ReplicationRule {bool m_is_enable;std::string m_id; // 用来标注具体 Rule 的名称std::string m_prefix; // 前缀匹配策略,不可重叠,重叠返回错误std::string m_dest_bucket; // 目标存储桶信息std::string m_dest_storage_class; // 存储类型,枚举值:STANDARD,STANDARD_IA
CosResult GetBucketReplication(const GetBucketReplicationReq& request, GetBucketReplicationResp* response);
qcloud_cos::CosConfig config("./config.json");qcloud_cos::CosAPI cos(config);std::string bucket_name = "examplebucket-1250000000";qcloud_cos::GetBucketReplicationReq req(bucket_name);qcloud_cos::GetBucketReplicationResp resp;qcloud_cos::CosResult result = cos.GetBucketReplication(req, &resp);if (result.IsSucc()) {// 请求成功,调用 resp 方法获取存储桶复制规则} else {// 请求失败,可以调用 CosResult 的成员函数输出错误信息,例如 requestID 等}
参数 | 参数描述 | 类型 | 是否必填 |
req | GetBucketReplication 操作的请求 | GetBucketReplicationReq | 是 |
resp | GetBucketReplication 操作的响应 | GetBucketReplicationResp | 是 |
std::string GetRole() const;std::vector<ReplicationRule> GetRules() const;
CosResult DeleteBucketReplication(const DeleteBucketReplicationReq& request, DeleteBucketReplicationResp* response);
qcloud_cos::CosConfig config("./config.json");qcloud_cos::CosAPI cos(config);std::string bucket_name = "examplebucket-1250000000";qcloud_cos::DeleteBucketReplicationReq req(bucket_name);qcloud_cos::DeleteBucketReplicationResp resp;qcloud_cos::CosResult result = cos.DeleteBucketReplication(req, &resp);if (result.IsSucc()) {// 请求成功} else {// 请求失败,可以调用 CosResult 的成员函数输出错误信息,例如 requestID 等}
参数 | 参数描述 | 类型 | 是否必填 |
req | DeleteBucketReplication 操作的请求 | DeleteBucketReplicationReq | 是 |
resp | DeleteBucketReplication 操作的响应 | DeleteBucketReplicationResp | 是 |
本页内容是否解决了您的问题?