PUT Bucket Versioning

Versioning can be used to restore an object that is incorrectly overwritten or deleted. You can use versioning to save, query, and restore objects of different versions. Versioning allows you to easily recover data lost 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 the versioning state is set to Enabled:

  • OBS creates a unique version ID for each uploaded object. Namesake objects are not overwritten and are distinguished by their own version IDs.
  • Objects can be downloaded by version ID. By default, the latest object is downloaded if the version ID is not specified.
  • Objects can be deleted by version ID. If an object is deleted with no version ID specified, the object is only attached with a deletion marker and a unique version ID but is not physically deleted.
  • The latest objects in a bucket are returned by default after a GET Object request. You can also send a request to obtain a bucket's objects with all version IDs.
  • Except deletion markers and object metadata, storage space occupied by objects with all version IDs is charged.

After the versioning state is set to Suspended:

  • Old version data remains on OBS.
  • OBS creates version ID null to an uploaded object and the object will be overwritten after a namesake one is uploaded.
  • Objects can be downloaded by version ID. By default, the latest object is downloaded if the version ID is not specified.
  • Objects can be deleted by version ID. If an object is deleted with no version ID specified, the object is attached with a deletion marker whose version ID is null. The object with version ID null is physically deleted.
  • Except deletion markers and object metadata, storage space occupied by objects with all version IDs is charged.

Only the bucket owner can set the bucket versioning state.

Request Syntax

PUT /?versioning HTTP/1.1
Host: bucketname.obs.cn-north-1.myhwclouds.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 Common Request Headers.

Request Elements

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

Table 1 Elements for configuring bucket versioning

Element

Description

Required or Optional

VersioningConfiguration

Indicates the root element for configuring the versioning state.

Ancestor: none

Required

Status

Indicates the versioning state of the bucket.

Type: enumeration

Ancestor: VersioningConfiguration

Valid values: Enabled, Suspended

Required

Response Syntax

HTTP/1.1 status_code
Date: date

Content-Length: length

Response Headers

This response uses common headers. For details, see Common Response Headers.

Response Elements

This response contains no element.

Error Responses

No special error responses are returned. For details about error responses, see Table 1.

Registration