tencent cloud

masukan

Versioning

Terakhir diperbarui:2024-02-02 16:24:05

    Overview

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

    Setting Versioning

    Feature description

    This API is used to set the versioning configuration for a bucket.

    Method prototype

    public void setBucketVersioningConfiguration(SetBucketVersioningConfigurationRequest setBucketVersioningConfigurationRequest)
    throws CosClientException, CosServiceException;

    Parameter description

    Parameter
    Description
    Type
    setBucketVersioningConfigurationRequest
    Versioning configuration
    SetBucketVersioningConfigurationRequest

    Response description

    Success: no value is returned.
    Failure: an error (such as authentication failure) occurs, with a CosClientException or CosServiceException exception thrown. For more information, please see Troubleshooting.

    Sample request

    Enable versioning
    String bucketName = "examplebucket-1250000000";
    // Enable versioning
    cosClient.setBucketVersioningConfiguration(
    new SetBucketVersioningConfigurationRequest(bucketName,
    new BucketVersioningConfiguration(BucketVersioningConfiguration.ENABLED)));
    Suspending Versioning
    String bucketName = "examplebucket-1250000000";
    // Suspend versioning
    cosClient.setBucketVersioningConfiguration(
    new SetBucketVersioningConfigurationRequest(bucketName,
    new BucketVersioningConfiguration(BucketVersioningConfiguration.SUSPENDED)));

    Querying Versioning

    Feature description

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

    Method prototype

    // Method 1: enter the bucket name
    public BucketVersioningConfiguration getBucketVersioningConfiguration(String bucketName)
    throws CosClientException, CosServiceException;
    
    // Method 2: get the configuration through GetBucketVersioningConfigurationRequest
    public BucketVersioningConfiguration getBucketVersioningConfiguration(
    GetBucketVersioningConfigurationRequest getBucketVersioningConfigurationRequest)
    throws CosClientException, CosServiceException;

    Sample request

    String bucketName = "examplebucket-1250000000";
    // Get versioning information
    BucketVersioningConfiguration bvc =
    cosClient.getBucketVersioningConfiguration(bucketName);
    // Get versioning information
    BucketVersioningConfiguration bvc2 = cosClient.getBucketVersioningConfiguration(
    new GetBucketVersioningConfigurationRequest(bucketName));

    Parameter description

    Parameter
    Description
    Type
    bucketName
    Bucket name in the format of BucketName-APPID. For more information, please see Naming Conventions
    String
    getBucketVersioningConfigurationRequest
    Request to get the versioning configuration
    GetBucketVersioningConfigurationRequest

    Response description

    Success: the versioning configuration of the bucket is returned.
    Failure: an error (such as authentication failure) occurs, with a CosClientException or CosServiceException exception thrown. For more information, please see Troubleshooting.
    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