tencent cloud

masukan

Versioning

Terakhir diperbarui:2024-02-02 14:36:36

    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

    Description

    This API is used to set the versioning configuration of a specified bucket. Once enabled, versioning can only be suspended but not disabled.

    Sample code

    // Bucket name in the format of bucketname-APPID. You can get APPID by referring to https://console.tencentcloud.com/developer.
    string bucket = "examplebucket-1250000000";
    PutBucketVersioningRequest request = new PutBucketVersioningRequest(bucket);
    request.IsEnableVersionConfig(true); //true: enable versioning; false: suspend versioning
    
    try
    {
    PutBucketVersioningResult result = cosXml.PutBucketVersioning(request);
    Console.WriteLine(result.GetResultInfo());
    }
    catch (COSXML.CosException.CosClientException clientEx)
    {
    Console.WriteLine("CosClientException: " + clientEx);
    }
    catch (COSXML.CosException.CosServerException serverEx)
    {
    Console.WriteLine("CosServerException: " + serverEx.GetInfo());
    }
    Note:
    For the complete sample, go to GitHub.

    Querying versioning

    Description

    This API is used to query the versioning configuration of a specified bucket.
    To get the versioning status of a bucket, you need to have read permission for the bucket.
    There are three versioning statuses: not enabled, enabled, and suspended.

    Sample code

    // Bucket name in the format of bucketname-APPID. You can get APPID by referring to https://console.tencentcloud.com/developer.
    string bucket = "examplebucket-1250000000";
    GetBucketVersioningRequest request = new GetBucketVersioningRequest(bucket);
    
    try
    {
    GetBucketVersioningResult result = cosXml.GetBucketVersioning(request);
    // Bucket lifecycle configuration
    VersioningConfiguration conf = result.versioningConfiguration;
    }
    catch (COSXML.CosException.CosClientException clientEx)
    {
    Console.WriteLine("CosClientException: " + clientEx);
    }
    catch (COSXML.CosException.CosServerException serverEx)
    {
    Console.WriteLine("CosServerException: " + serverEx.GetInfo());
    }
    Note:
    For the complete sample, go to GitHub.
    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