Updated on 2022-02-10 GMT+08:00

GET Object versions

API Description

You can use this API to list versioning objects in a bucket. By default, a maximum of 1000 versioning objects are listed.

Method Definition

ObsClient.listVersions

Request Parameter

Field

Type

Optional or Mandatory

Description

Bucket

String

Mandatory

Bucket name

RequestDate

String

or

Date

Optional

Request time

NOTE:

When the parameter type is String, the value must comply with the ISO8601 or RFC822 standards.

Prefix

String

Optional

Name prefix that the objects to be listed must contain

KeyMarker

String

Optional

Object name to start with when listing versioning objects in a bucket. All versioning objects whose names follow this parameter are listed in the lexicographical order.

MaxKeys

Number

Optional

Maximum number of versioning objects returned. The value ranges from 1 to 1000. If the value is not in this range, 1000 is returned by default.

Delimiter

String

Optional

Character used to group object names. If the object name contains the Delimiter parameter, the character string from the first character to the first delimiter in the object name is grouped under a single result element, CommonPrefix. (If a prefix is specified in the request, the prefix must be removed from the object name.)

VersionIdMarker

String

Optional

Object name to start with when listing versioning objects in a bucket. All versioning objects are listed in the lexicographical order by object name and version ID. This parameter must be used together with KeyMarker.

If the value of VersionIdMarker is not a version ID specified by KeyMarker, VersionIdMarker is ineffective.

Returned Result (InterfaceResult)

Field

Type

Description

RequestId

String

Request ID returned by the OBS server

Location

String

Bucket location

Bucket

String

Bucket name

Delimiter

String

Character used to group versioning object names, which is consistent with that set in the request

Prefix

String

Name prefix of versioning objects, which is consistent with that set in the request

IsTruncated

String

Whether all versioning objects are returned. If the field value is true, not all versioning objects are returned. If the field value is false, all versioning objects are returned.

KeyMarker

String

Object name to start with for listing versioning objects, which is consistent with that set in the request

VersionIdMarker

String

Start position for listing objects, which is consistent with that set in the request

NextKeyMarker

String

Object name to start with upon the next request for listing versioning objects in a bucket

NextVersionIdMarker

String

Version ID to start with upon the next request for listing versioning objects. It is used with the NextKeyMarker parameter.

MaxKeys

String

Maximum number of listed versioning objects, which is consistent with that set in the request

Versions

Array

List of versioning objects

  

ETag

String

MD5 value of the object

Size

String

Object size in bytes

Key

String

Object name

VersionId

String

Object version ID

IsLatest

String

Whether the object is of the latest version. If the field value is true, the object is of the latest version.

LastModified

String

Time when the last modification was made to the object

Owner

Object

Object owner

  

ID

String

ID of the domain to which the object owner belongs

  

StorageClass

String

Storage class of the object

  

Type

String

Whether the object is an appendable object

DeleteMarkers

Array

List of versioning delete markers

  

Owner

Object

Object owner

  

ID

String

ID of the domain to which the object owner belongs

Key

String

Object name

VersionId

String

Object version ID

IsLatest

String

Whether the object is of the latest version. If the field value is true, the object is of the latest version.

LastModified

String

Time when the last modification was made to the object

CommonPrefixes

Array

List of object name prefixes grouped according to the Delimiter parameter (if specified)

  

Prefix

String

Object name prefix grouped according to the Delimiter parameter

Sample Code

obsClient.listVersions({
       Bucket : 'bucketname',
       Prefix : 'prefix',
       MaxKeys : 100
},function (err, result) {
       if(err){
              console.error('Error-->' + err);
       }else{
              if(result.CommonMsg.Status < 300){
                     console.log('RequestId-->' + result.InterfaceResult.RequestId);
                     console.log('Versions:');
                     for(var j=0;j<result.InterfaceResult.Versions;j++){
                           console.log('Version[' + j +  ']:');
                           console.log('Key-->' + result.InterfaceResult.Versions[j]['Key']);
                           console.log('VersionId-->' + result.InterfaceResult.Versions[j]['VersionId']);
                           console.log('IsLatest-->' + result.InterfaceResult.Versions[j]['IsLatest']);
                           console.log('LastModified-->' + result.InterfaceResult.Versions[j]['LastModified']);
                           console.log('ETag-->' + result.InterfaceResult.Versions[j]['ETag']);
                           console.log('Size-->' + result.InterfaceResult.Versions[j]['Size']);
                           console.log('Owner[ID]-->' + result.InterfaceResult.Versions[j]['Owner']['ID']);
                           console.log('StorageClass-->' + result.InterfaceResult.Versions[j]['StorageClass']);
                     }
                     console.log('DeleteMarkers:');
                     for(var i=0;i<result.InterfaceResult.DeleteMarkers.length;i++){
                           console.log('DeleteMarker[' + i +  ']:');
                           console.log('Key-->' + result.InterfaceResult.DeleteMarkers[i]['Key']);
                           console.log('VersionId-->' + result.InterfaceResult.DeleteMarkers[i]['VersionId']);
                           console.log('IsLatest-->' + result.InterfaceResult.DeleteMarkers[i]['IsLatest']);
                           console.log('LastModified-->' + result.InterfaceResult.DeleteMarkers[i]['LastModified']);
                           console.log('Owner[ID]-->' + result.InterfaceResult.DeleteMarkers[i]['Owner']['ID']);
                     }
              }else{
                     console.log('Code-->' + result.CommonMsg.Code);
                     console.log('Message-->' + result.CommonMsg.Message);
              }
       }
});