tencent cloud

masukan

Versioning

Terakhir diperbarui:2024-02-02 12:12:57

    Overview

    This document provides an overview of APIs and SDK code samples related to versioning.
    API
    Operation
    Description
    Setting versioning
    Sets versioning for a bucket
    Querying versioning
    Queries the versioning information of a bucket

    Setting Versioning

    Feature description

    This API (PUT Bucket versioning) is used to set the versioning configuration for a bucket.

    Method prototype

    CosResult BucketOp::PutBucketVersioning(const PutBucketVersioningReq& req, PutBucketVersioningResp* resp);

    Sample request

    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 versioning
    req.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

    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);

    Querying Versioning

    Feature description

    This API is used to query the versioning configuration of a bucket.

    Method prototype

    CosResult CosAPI::GetBucketVersioning(const GetBucketVersioningReq& request, GetBucketVersioningResp* response);

    Sample request

    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

    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;
    
    Hubungi Kami

    Hubungi tim penjualan atau penasihat bisnis kami untuk membantu bisnis Anda.

    Dukungan Teknis

    Buka tiket jika Anda mencari bantuan lebih lanjut. Tiket kami tersedia 7x24.

    Dukungan Telepon 7x24