Configures the versioning state of a bucket.
Usage notes
-
You must have the PutBucketVersioning permission.
-
A bucket has one of three versioning states: disabled (default), enabled, or suspended.
-
When enabled, OSS assigns unique version IDs to all objects added to the bucket and retains multiple versions.
-
When suspended, OSS assigns version ID null to new objects and does not retain versions for deleted or overwritten objects.
For more information about versioning, see Versioning.
Request syntax
PUT /?versioning HTTP/1.1
Host: BucketName.oss-cn-hangzhou.aliyuncs.com
Date: GMT Date
Authorization: SignatureValue
<?xml version="1.0" encoding="UTF-8"?>
<VersioningConfiguration>
<Status>Enabled</Status>
</VersioningConfiguration>
Request headers
DescribeRegions uses only common request headers. For more information, see Common request headers.
Request parameters
|
Parameter |
Type |
Required |
Example |
Description |
|
VersioningConfiguration |
Container |
Yes |
N/A |
Container for the bucket versioning state. Child nodes: Status Parent nodes: none |
|
Status |
String |
Yes |
Enabled |
Versioning state of the bucket. Parent nodes: VersioningConfiguration Valid values:
|
Response headers
The response contains only common response headers. For more information, see Common response headers.
Examples
-
Sample request: enable versioning
PUT /?versioning HTTP/1.1 Host: bucket-versioning.oss-cn-hangzhou.aliyuncs.com Date: Tue, 09 Apr 2019 02:20:12 GMT Authorization: OSS qn6q**************:77Dv**************** <?xml version="1.0" encoding="UTF-8"?> <VersioningConfiguration> <Status>Enabled</Status> </VersioningConfiguration>Sample response
HTTP/1.1 200 OK x-oss-request-id: 5CAC015CB7AEADE01700**** Date: Tue, 09 Apr 2019 02:20:12 GMT Content-Length: 0 Connection: keep-alive Server: AliyunOSS -
Sample request: suspend versioning
PUT /?versioning HTTP/1.1 Host: bucket-versioning.oss-cn-hangzhou.aliyuncs.com Date: Tue, 09 Apr 2019 02:28:18 GMT Authorization: OSS qn6q**************:77Dv**************** <?xml version="1.0" encoding="UTF-8"?> <VersioningConfiguration> <Status>Suspended</Status> </VersioningConfiguration>Sample response
HTTP/1.1 200 OK x-oss-request-id: 5CAC0342B7AEADE01700**** Date: Tue, 09 Apr 2019 02:28:18 GMT Content-Length: 0 Connection: keep-alive Server: AliyunOSS
OSS SDKs
Call PutBucketVersioning with the following OSS SDKs:
ossutil
For information about the ossutil command that corresponds to the PutBucketVersioning operation, see put-bucket-versioning.
Error codes
|
Error code |
HTTP status code |
Description |
|
AccessDenied |
403 |
You do not have permission to configure versioning for this bucket. |
|
InvalidArgument |
400 |
The specified versioning state is invalid. Valid values: Enabled and Suspended. |