API | Operation | Description |
Setting versioning | Sets versioning for a bucket | |
Querying versioning | Queries the versioning information of a bucket |
CosResult BucketOp::PutBucketVersioning(const PutBucketVersioningReq& req, PutBucketVersioningResp* resp);
qcloud_cos::CosConfig config("./config.json");qcloud_cos::CosAPI cos(config);std::string bucket_name = "examplebucket-1250000000";qcloud_cos::PutBucketVersioningReq req(bucket_name);qcloud_cos::PutBucketVersioningResp resp;// Enable versioningreq.SetStatus(true);qcloud_cos::CosResult result = cos.PutBucketVersioning(req, &resp);if (result.IsSucc()) {// Request successful} else {// Request failed. You can call the CosResult member functions to output the error information, such as requestID.}
Parameter | Description | Type | Required |
req | Request of the PutBucketVersioning operation | PutBucketVersioningReq | Yes |
resp | Response of the PutBucketVersioning operation | PutBucketVersioningResp | Yes |
PutBucketVersioningReq
provides the following method to enable/suspend versioning:void SetStatus(bool is_enable);
CosResult CosAPI::GetBucketVersioning(const GetBucketVersioningReq& request, GetBucketVersioningResp* response);
qcloud_cos::CosConfig config("./config.json");qcloud_cos::CosAPI cos(config);std::string bucket_name = "examplebucket-1250000000";qcloud_cos::GetBucketVersioningReq req(bucket_name);qcloud_cos::GetBucketVersioningResp resp;qcloud_cos::CosResult result = cos.GetBucketVersioning(req, &resp);if (result.IsSucc()) {// Request successful. You can obtain the versioning status via the resp method.} else {// Request failed. You can call the CosResult member functions to output the error information, such as requestID.}
Parameter | Description | Type | Required |
req | Request of the GetBucketVersioning operation | GetBucketVersioningReq | Yes |
resp | Response of the GetBucketVersioning operation | GetBucketVersioningResp | Yes |
GetBucketVersioningResp
provides the following method to obtain the status of versioning:int GetStatus() const;
Was this page helpful?