tencent cloud

All product documents
Cloud Object Storage
Versioning
Last updated: 2025-02-06 16:41:27
Versioning
Last updated: 2025-02-06 16:41:27

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 enable or suspend versioning for a bucket.
Note:
1. If you have never enabled versioning for the bucket, GET Bucket versioning will not return a versioning status.
2. Once enabled, versioning can only be suspended but cannot be disabled.
3. Set the versioning status value to Enabled or Suspended to enable or suspend versioning, respectively.
4. To set versioning for a bucket, you need to have write permission for the bucket.

Sample request

cos.putBucketVersioning({
Bucket: 'examplebucket-1250000000', /*Required*/
Region: 'COS_REGION', /* Bucket region. Required */
VersioningConfiguration: {
Status: "Enabled"
}
}, function (err, data) {
console.log(err || data);
});

Parameter description

Parameter Name
Description
Type
Required
Bucket
Bucket for which versioning is enabled or suspended in the format: BucketName-APPID
String
Yes
Region
Bucket region. For the enumerated values, see Regions and Access Domain Names
String
Yes
VersioningConfiguration
Defines the versioning configuration of the bucket
Object
Yes
- Status
Versioning status; enumerated values: Enabled, Suspended
String
No

Callback function description

function(err, data) { ... }
Parameter Name
Description
Type
err
Object returned when an error (network error or service error) occurs. If the request is successful, this is null. For more information, see Error Codes
Object
- statusCode
HTTP status code returned by the request, such as 200, 403, and 404
Number
- headers
Headers returned by the request
Object
data
Data returned when the request is successful. If the request fails, this is null
Object
- statusCode
HTTP status code returned by the request, such as 200, 403, and 404
Number
- headers
Headers returned by the request
Object

Querying versioning

Feature description

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

Sample request

cos.getBucketVersioning({
Bucket: 'examplebucket-1250000000', /*Required*/
Region: 'COS_REGION', /* Bucket region. Required */
}, function (err, data) {
console.log(err || data);
});

Parameter description

Parameter Name
Description
Type
Required
Bucket
Bucket for which versioning is queried in the format: BucketName-APPID
String
Yes
Region
Bucket region. For the enumerated values, see Regions and Access Domain Names
String
Yes

Callback function description

function(err, data) { ... }
Parameter Name
Description
Type
err
Object returned when an error (network error or service error) occurs. If the request is successful, this is null. For more information, see Error Codes
Object
- statusCode
HTTP status code returned by the request, such as 200, 403, and 404
Number
- headers
Headers returned by the request
Object
data
Data returned when the request is successful. If the request fails, this is null
Object
- statusCode
HTTP status code returned by the request, such as 200, 403, and 404
Number
- headers
Headers returned by the request
Object
- VersioningConfiguration
Versioning configuration of the bucket. If never disabled, it is null '{}'.
Object
- - Status
Versioning status; enumerated values: Enabled, Suspended
String

Was this page helpful?
You can also Contact Sales or Submit a Ticket for help.
Yes
No

Feedback

Contact Us

Contact our sales team or business advisors to help your business.

Technical Support

Open a ticket if you're looking for further assistance. Our Ticket is 7x24 avaliable.

7x24 Phone Support
Hong Kong, China
+852 800 906 020 (Toll Free)
United States
+1 844 606 0804 (Toll Free)
United Kingdom
+44 808 196 4551 (Toll Free)
Canada
+1 888 605 7930 (Toll Free)
Australia
+61 1300 986 386 (Toll Free)
EdgeOne hotline
+852 300 80699
More local hotlines coming soon