Overview
This document provides an overview of APIs and SDK code samples related to versioning.
Setting versioning
Feature description
This API is used to enable or suspend versioning for a bucket.
- If you have never enabled versioning for the bucket, GET Bucket versioning will not return a versioning status.
- Once enabled, versioning can only be suspended but cannot be disabled.
- Set the versioning status value to
Enabled
or Suspended
to enable or suspend versioning, respectively.
- To set versioning for a bucket, you need to have write permission for the bucket.
Sample request
cos.putBucketVersioning({
Bucket: 'examplebucket-1250000000',
Region: 'COS_REGION',
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',
Region: 'COS_REGION',
}, 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?