List Object Versions
List All Versions of an Object Through Pagination
Enabling Versioning in a bucket allows you to store multiple versions of the same object in the bucket. Each version of the object will have its own versionId. This SDK method allows you to get all the existing versions of an object present in a bucket by pagination. The Object reference used in the below code snippet is the component instance.
Parameters Used
Parameter Name | Data Type | Definition |
---|---|---|
nextToken | String | Will hold the value to determine the next set of versions. |
maxVersions | int | An Optional parameter. Will hold the value of the maximum number of versions of the object that can be listed per iteration. |
async function listMyPaginatedVersions(maxVersion = undefined, nextToken = undefined) {
const response = await objectIns.listPagedVersions({ maxVersion, nextToken});
console.log(response.version);
if(response.is_truncated) {
listMyPaginatedVersions(maxVersion,nextToken)
}
}
await listMyPaginatedVersions(10);
Example Response
{
"key": "sam/out/sample.txt",
"versions_count": 2,
"max_versions": "2",
"is_truncated": "False",
"next_continuation_token": "4YpUdkktt2UeWp6MwEK1LZXELnuVhunHLnGgX29uvszwtJEQE2gVDJYyRiLdUmhNst",
"version": [
{
"version_id": "01hyfh12njtpyvzwq6p1fd2d8s",
"is_latest": "True",
"last_modified": "May 22, 2024 12:20 PM",
"size": 1,
"etag": "9af7c117d9de9a06fba7a5f1ea5fcc2d"
},
{
"version_id": "01hyfh0xkvwkxxsjfceef201xa",
"is_latest": "False",
"last_modified": "May 22, 2024 12:20 PM",
"size": "1",
"etag": "9af7c117d9de9a06fba7a5f1ea5fcc2d"
}
]
}
List All Versions of the Object Through Iteration
You can use the following SDK method to get all available versions of the object in a single call.
const versions = objectIns.listIterableVersions();
for await( const version of versions) {
console.log(version);
}
Example Response
{
"versionId": "01hyfh12njtpyvzwq6p1fd2d8s",
"is_latest": "True",
"last_modified": "May 22,2024 12:20 PM",
"size": "1", "etag": "9af7c117d9de9a06fba7a5f1ea5fcc2d"
}
{
"versionId": "01hyfh0xkvwkxxsjfceef201xa",
"is_latest": "False",
"last_modified": "May 22, 2024 12:20 PM",
"size": "1",
"etag": "9af7c117d9de9a06fba7a5f1ea5fcc2d"
}
Last Updated 2025-07-02 15:43:56 +0530 IST
Yes
No
Send your feedback to us