ListObjectVersions
Returns metadata about all versions of the objects in a bucket. You can also use request parameters as selection criteria to return metadata about a subset of all the object versions.
A 200 OK
response can contain valid or invalid XML. Make sure to design your application to parse the contents of the response and handle it appropriately.
Permissions
Action | Description | Resource |
---|---|---|
ListBucketVersions | Grants permission to list the versions from a bucket | object |
The following operations are related to ListObjectVersions:
Request Syntax
GET /Bucket?versions&delimiter=Delimiter&key-marker=KeyMarker&max-keys=MaxKeys&prefix=Prefix&version-id-marker=VersionIdMarker HTTP/1.1
Host: <partition>.s3.astran.io
URI Request Parameters
The request uses the following URI parameters.
The bucket name containing the objects.
Required: Yes
A delimiter is a character that you specify to group keys. All keys that contain the same string between the prefix
and the first occurrence of the delimiter are grouped under a single result element in CommonPrefixes
. These groups are counted as one result against the max-keys
limitation. These keys are not returned elsewhere in the response.
Specifies the key to start with when listing objects in a bucket.
Sets the maximum number of keys returned in the response. By default, the action returns up to 1,000 key names. The response might contain fewer keys but will never contain more. If additional keys satisfy the search criteria, but were not returned because max-keys
was exceeded, the response contains <isTruncated>true</isTruncated>
. To return the additional keys, see key-marker
and version-id-marker
.
Use this parameter to select only those keys that begin with the specified prefix. You can use prefixes to separate a bucket into different groupings of keys. (You can think of using prefix to make groups in the same way that you'd use a folder in a file system.) You can use prefix
with delimiter
to roll up numerous objects into a single result under CommonPrefixes
.
Specifies the object version you want to start listing from.
Request Body
The request does not have a request body.
Response syntax
HTTP/1.1 200
<?xml version="1.0" encoding="UTF-8"?>
<ListVersionsResult>
<IsTruncated>boolean</IsTruncated>
<KeyMarker>string</KeyMarker>
<VersionIdMarker>string</VersionIdMarker>
<NextKeyMarker>string</NextKeyMarker>
<NextVersionIdMarker>string</NextVersionIdMarker>
<Version>
<ETag>string</ETag>
<IsLatest>boolean</IsLatest>
<Key>string</Key>
<LastModified>timestamp</LastModified>
<Size>long</Size>
<VersionId>string</VersionId>
</Version>
...
<DeleteMarker>
<IsLatest>boolean</IsLatest>
<Key>string</Key>
<LastModified>timestamp</LastModified>
<VersionId>string</VersionId>
</DeleteMarker>
...
<Name>string</Name>
<Prefix>string</Prefix>
<Delimiter>string</Delimiter>
<MaxKeys>integer</MaxKeys>
<CommonPrefixes>
<Prefix>string</Prefix>
</CommonPrefixes>
</ListVersionsResult>
Response elements
Rool level tag for the ListVersionsResult parameters
Required: Yes
All of the keys rolled up into a common prefix count as a single return when calculating the number of returns.
Type: Array of CommonPrefix data types
All of the keys rolled up into a common prefix count as a single return when calculating the number of returns.
Type: Array of DeleteMarkerEntry data types
The delimiter grouping the included keys. A delimiter is a character that you specify to group keys. All keys that contain the same string between the prefix and the first occurrence of the delimiter are grouped under a single result element in CommonPrefixes. These groups are counted as one result against the max-keys limitation. These keys are not returned elsewhere in the response.
Type: String
A flag that indicates whether Astran S3 returned all of the results that satisfied the search criteria. If your results were truncated, you can make a follow-up paginated request by using the NextKeyMarker
and NextVersionIdMarker
response parameters as a starting place in another request to return the rest of the results.
Type: Boolean
Marks the last key returned in a truncated response.
Type: String
Specifies the maximum number of objects to return.
Type: Integer
The bucket name.
Type: String
When the number of responses exceeds the value of MaxKeys
, NextKeyMarker
specifies the first key not returned that satisfies the search criteria. Use this value for the key-marker
request parameter in a subsequent request.
Type: String
When the number of responses exceeds the value of MaxKeys
, NextVersionIdMarker
specifies the first object version not returned that satisfies the search criteria. Use this value for the version-id-marker
request parameter in a subsequent request.
Type: String
Selects objects that start with the value supplied by this parameter.
Type: String
Container for version information.
Type: Array of ObjectVersion data types
Marks the last version of the key returned in a truncated response.
Type: String
Examples
Sample Request
The following request returns all of the versions of all of the objects in the specified bucket.
GET /bucketname?versions HTTP/1.1
Host: <partition>.s3.astran.io
Date: Mon, 25 Sep 2024 09:09:17 GMT
Authorization: authorization string
Sample Response
This example illustrates one usage of ListObjectVersions.
<?xml version="1.0" encoding="UTF-8"?>
<ListVersionsResult xmlns="http://s3.amazonaws.com/doc/2006-03-01">
<Name>bucketname</Name>
<Prefix>my</Prefix>
<KeyMarker/>
<VersionIdMarker/>
<MaxKeys>5</MaxKeys>
<IsTruncated>false</IsTruncated>
<Version>
<Key>my-image.jpg</Key>
<VersionId>some_version_id</VersionId>
<IsLatest>true</IsLatest>
<LastModified>2009-10-12T17:50:30.000Z</LastModified>
<ETag>some_etag</ETag>
<Size>434234</Size>
</Version>
<Version>
<Key>my-second-image.jpg</Key>
<VersionId>some_version_id</VersionId>
<IsLatest>false</IsLatest>
<LastModified>2009-10-10T17:50:30.000Z</LastModified>
<ETag>some_etag</ETag>
<Size>166434</Size>
</Version>
<Version>
<Key>my-third-image.jpg</Key>
<VersionId>some_version_id</VersionId>
<IsLatest>false</IsLatest>
<LastModified>2009-10-11T12:50:30.000Z</LastModified>
<ETag>some_etag</ETag>
<Size>64</Size>
</Version>
<DeleteMarker>
<Key>my-second-image.jpg</Key>
<VersionId>some_version_id</VersionId>
<IsLatest>true</IsLatest>
<LastModified>2009-11-12T17:50:30.000Z</LastModified>
</DeleteMarker>
<DeleteMarker>
<Key>my-third-image.jpg</Key>
<VersionId>some_version_id</VersionId>
<IsLatest>true</IsLatest>
<LastModified>2009-10-15T17:50:30.000Z</LastModified>
</DeleteMarker>
</ListVersionsResult>
Sample Request
The following request returns objects in the order that they were stored, returning the most recently stored object first, starting with the value for key-marker
.
GET /bucketname?versions&key-marker=key2 HTTP/1.1
Host: <partition>.s3.astran.io
Date: Mon, 25 Sep 2024 09:09:17 GMT
Authorization: signatureValue
Sample Response
<?xml version="1.0" encoding="UTF-8"?>
<ListVersionsResult xmlns="http://s3.amazonaws.com/doc/2006-03-01/">
<Name>bucketname</Name>
<Prefix/>
<KeyMarker>key2</KeyMarker>
<VersionIdMarker/>
<MaxKeys>1000</MaxKeys>
<IsTruncated>false</IsTruncated>
<Version>
<Key>key3</Key>
<VersionId>some_version_id</VersionId>
<IsLatest>true</IsLatest>
<LastModified>2009-12-09T00:19:04.000Z</LastModified>
<ETag>some_etag</ETag>
<Size>217</Size>
</Version>
<Version>
<Key>sourcekey</Key>
<VersionId>some_version_id</VersionId>
<IsLatest>false</IsLatest>
<LastModified>2009-12-10T16:37:44.000Z</LastModified>
<ETag>some_etag</ETag>
<Size>217</Size>
</Version>
<DeleteMarker>
<Key>sourcekey</Key>
<VersionId>some_version_id</VersionId>
<IsLatest>true</IsLatest>
<LastModified>2009-12-10T16:38:11.000Z</LastModified>
</DeleteMarker>
</ListVersionsResult>
Sample Request Using the prefix Parameter
This example returns objects whose keys begin with source
.
GET /bucketname?versions&prefix=source HTTP/1.1
Host: <partition>.s3.astran.io
Date: Mon, 25 Sep 2024 09:09:17 GMT
Authorization: authorization string
Sample Response
This example illustrates one usage of ListObjectVersions.
<?xml version="1.0" encoding="UTF-8"?>
<ListVersionsResult xmlns="http://s3.amazonaws.com/doc/2006-03-01/">
<Name>bucketname</Name>
<Prefix>source</Prefix>
<KeyMarker/>
<VersionIdMarker/>
<MaxKeys>1000</MaxKeys>
<IsTruncated>false</IsTruncated>
<DeleteMarker>
<Key>sourcekey</Key>
<VersionId>some_version_id</VersionId>
<IsLatest>true</IsLatest>
<LastModified>2009-12-10T16:38:11.000Z</LastModified>
</DeleteMarker>
<Version>
<Key>sourcekey</Key>
<VersionId>some_version_id</VersionId>
<IsLatest>false</IsLatest>
<LastModified>2009-12-10T16:37:44.000Z</LastModified>
<ETag>some_etag</ETag>
<Size>217</Size>
</Version>
</ListVersionsResult>
Sample Request: Using the key-marker and version-id-marker Parameters
The following example returns objects starting at the specified key (key-marker
) and version ID (version-id-marker
).
GET /bucketname?versions&key-marker=key3&version-id-marker=t46ZenlYTZBnj HTTP/1.1
Host: <partition>.s3.astran.io
Date: Mon, 25 Sep 2024 09:09:17 GMT
Authorization: signatureValue
Sample Response
This example illustrates one usage of ListObjectVersions.
<?xml version="1.0" encoding="UTF-8"?>
<ListVersionsResult xmlns="http://s3.amazonaws.com/doc/2006-03-01/">
<Name>bucketname</Name>
<Prefix/>
<KeyMarker>key3</KeyMarker>
<VersionIdMarker>t46ZenlYTZBnj</VersionIdMarker>
<MaxKeys>1000</MaxKeys>
<IsTruncated>false</IsTruncated>
<DeleteMarker>
<Key>sourcekey</Key>
<VersionId>some_version_id</VersionId>
<IsLatest>true</IsLatest>
<LastModified>2009-12-10T16:38:11.000Z</LastModified>
</DeleteMarker>
<Version>
<Key>sourcekey</Key>
<VersionId>some_version_id</VersionId>
<IsLatest>false</IsLatest>
<LastModified>2009-12-10T16:37:44.000Z</LastModified>
<ETag>some_etag</ETag>
<Size>217</Size>
</Version>
</ListVersionsResult>
Sample Request: Using the key-marker, version-id-marker, and max-keys Parameters
The following request returns up to three (the value of max-keys
) objects starting with the key specified by key-marker
and the version ID specified by version-id-marker
.
Get/bucketname?versions&key-marker=key3&version-id-marker=t46Z0menlYTZBnj&max-keys=3
Host: <partition>.s3.astran.io
Date: Mon, 25 Sep 2024 09:09:17 GMT
Authorization: authorization string
Sample Response
This example illustrates one usage of ListObjectVersions.
<?xml version="1.0" encoding="UTF-8"?>
<ListVersionsResult xmlns="http://s3.amazonaws.com/doc/2006-03-01/">
<Name>bucketname</Name>
<Prefix/>
<KeyMarker>key3</KeyMarker>
<VersionIdMarker>null</VersionIdMarker>
<NextKeyMarker>key3</NextKeyMarker>
<NextVersionIdMarker>d-d309mfjFrUmoQ0DBsVqmcMV15OI.</NextVersionIdMarker>
<MaxKeys>3</MaxKeys>
<IsTruncated>true</IsTruncated>
<Version>
<Key>key3</Key>
<VersionId>some_version_id</VersionId>
<IsLatest>false</IsLatest>
<LastModified>2009-12-09T00:18:23.000Z</LastModified>
<ETag>some_etag</ETag>
<Size>217</Size>
</Version>
<Version>
<Key>key3</Key>
<VersionId>some_version_id</VersionId>
<IsLatest>false</IsLatest>
<LastModified>2009-12-09T00:18:08.000Z</LastModified>
<ETag>some_etag</ETag>
<Size>217</Size>
</Version>
</ListVersionsResult>
Sample Request: Using the delimiter and prefix Parameters
Assume you have the following keys in your bucket, example-bucket
.
photos/2006/January/sample.jpg
photos/2006/February/sample.jpg
photos/2006/March/sample.jpg
videos/2006/March/sample.wmv
sample.jpg
The following GET
versions request specifies the delimiter
parameter with the value /
.
Get/bucketname?versions&delimiter=/ HTTP/1.1
Host: <partition>.s3.astran.io
Date: Mon, 25 Sep 2024 09:09:17 GMT
Authorization: authorization string
Sample Response
The list of keys from the specified bucket is shown in the following response.
The response returns the sample.jpg
key in a Version
element. However, because all the other keys contain the specified delimiter, a distinct substring, from the beginning of the key to the first occurrence of the delimiter, from each of these keys is returned in a CommonPrefixes
element. The key substrings, photos/
and videos/
, in the CommonPrefixes
element indicate that there are one or more keys with these key prefixes.
This is a useful scenario if you use key prefixes for your objects to create a logical folder-like structure. In this case, you can interpret the result as the folders photos/
and videos/
have one or more objects.
<ListVersionsResult xmlns="http://s3.amazonaws.com/doc/2006-03-01/">
<Name>bucketname</Name>
<Prefix></Prefix>
<KeyMarker></KeyMarker>
<VersionIdMarker></VersionIdMarker>
<MaxKeys>1000</MaxKeys>
<Delimiter>/</Delimiter>
<IsTruncated>false</IsTruncated>
<Version>
<Key>Sample.jpg</Key>
<VersionId>some_version_id</VersionId>
<IsLatest>true</IsLatest>
<LastModified>2011-02-02T18:46:20.000Z</LastModified>
<ETag>some_etag</ETag>
<Size>3191</Size>
</Version>
<CommonPrefixes>
<Prefix>photos/</Prefix>
</CommonPrefixes>
<CommonPrefixes>
<Prefix>videos/</Prefix>
</CommonPrefixes>
</ListVersionsResult>
Example
In addition to the delimiter
parameter, you can filter results by adding a prefix
parameter as shown in the following request.
Get/bucketname?versions&prefix=photos/2006/&delimiter=/ HTTP/1.1
Host: <partition>.s3.astran.io
Date: Mon, 25 Sep 2024 09:09:17 GMT
Authorization: authorization string
Example
In this case, the response will include only object keys that start with the specified prefix. The value returned in the CommonPrefixes
element is a substring from the beginning of the key to the first occurrence of the specified delimiter after the prefix.
<?xml version="1.0" encoding="UTF-8"?>
<ListVersionsResult xmlns="http://s3.amazonaws.com/doc/2006-03-01/">
<Name>bucketname</Name>
<Prefix>photos/2006/</Prefix>
<KeyMarker></KeyMarker>
<VersionIdMarker></VersionIdMarker>
<MaxKeys>1000</MaxKeys>
<Delimiter>/</Delimiter>
<IsTruncated>false</IsTruncated>
<CommonPrefixes>
<Prefix>photos/2006/February/</Prefix>
</CommonPrefixes>
<CommonPrefixes>
<Prefix>photos/2006/January/</Prefix>
</CommonPrefixes>
<CommonPrefixes>
<Prefix>photos/2006/March/</Prefix>
</CommonPrefixes>
</ListVersionsResult>
For more information about using this API in one of the language-specific AWS SDKs, see the following: