Configuring Versioning for a Bucket

Functions

This operation restores an object that is mistakenly overwritten or deleted. You can use versioning to save, query, and restore objects of different versions. Versioning allows you to easily recover lost data due to misoperations or program faults. Versioning can also be used for retaining and archiving data.

By default, versioning is disabled for a bucket.

You can perform this operation to enable or suspend versioning for a bucket.

After versioning is enabled for a bucket:

After versioning is suspended for a bucket:

Only the bucket owner can set versioning for the bucket.

Request Syntax

1
2
3
4
5
6
7
8
9
PUT /?versioning HTTP/1.1 
Host: bucketname.obs.region.example.com
Date: date
Authorization: authorization
Content-Length: length

<VersioningConfiguration> 
    <Status>status</Status> 
</VersioningConfiguration>

Request Parameters

This request contains no parameter.

Request Headers

This request uses common headers. For details, see Table 3.

Request Elements

This request contains elements to configure the bucket versioning in XML format. Table 1 lists the request elements.

Table 1 Elements for configuring bucket versioning

Element

Description

Mandatory

VersioningConfiguration

Root node for configuring versioning

Ancestor node: none

Yes

Status

Versioning status of the bucket

Type: enumeration

Ancestor node: VersioningConfiguration

Value options: Enabled, Suspended

Yes

Response Syntax

1
2
3
4
HTTP/1.1 status_code
Date: date

Content-Length: length

Response Headers

The response to the request uses common headers. For details, see Table 1.

Response Elements

This response involves no elements.

Error Responses

No special error responses are involved. For details about error responses, see Table 2.

Sample Request

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
PUT /?versioning HTTP/1.1
User-Agent: curl/7.29.0
Host: examplebucket.obs.region.example.com
Accept: */*
Date: WED, 01 Jul 2015 03:14:18 GMT
Authorization: OBS H4IPJX0TQTHTHEBQQCEC:sc2PM13Wlfcoc/YZLK0MwsI2Zpo=
Content-Length: 89

<VersioningConfiguration>     
    <Status>Enabled</Status> 
</VersioningConfiguration>

Sample Response

1
2
3
4
5
6
HTTP/1.1 200 OK
Server: OBS
x-obs-request-id: BF26000001643672B973EEBC5FBBF909
x-obs-id-2: 32AAAQAAEAABSAAgAAEAABAAAQAAEAABCSH6rPRHjQCa62fcNpCCPs7+1Aq/hKzE
Date: Date: WED, 01 Jul 2015 03:14:18 GMT
Content-Length: 0