List Versions of an Object
List All Versions of an Object
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.
Info: To use this SDK method, you need intialize it with Admin scope. You can learn more about this requirement from this section
Parameters Used
Parameter Name | Data Type | Definition |
---|---|---|
nextToken | String | Will hold the value to determine the next set of versions. |
maxVersion | int | An Optional parameter. Will hold the value of the maximum number of versions of the object that can be listed per iteration. |
Ensure the following packages are imported
copyimport com.zc.component.stratus.ZCBucket; import com.zc.component.stratus.ZCStratus; import com.zc.component.stratus.ZCPagedObjectResponse; import com.zc.component.stratus.ZCObject; import com.zc.component.stratus.beans.ZCObjectVersions; import com.zc.component.stratus.beans.ZCObjectVersions.ZCVersionDetail; import java.util.List;
copyString nextToken = null; int maxVersion = 5; do { ZCObjectVersions res = object.listPagedVersions(maxVersion, nextToken); System.out.println(res.getVersion()); for(ZCVersionDetail version : res.getVersion()) { System.out.println("version id: "+version.getVersionId()); } nextToken = res.getNextToken(); } while(nextToken != null);
List All Versions of the Object in an Iterable Manner
You can use the following SDK method to list all available versions of the object in a single call.
Info: To use this SDK method, you need intialize it with Admin scope. You can learn more about this requirement from this section
Ensure the following packages are imported
copyimport java.util.Iterator; import com.zc.component.stratus.beans.ZCObjectVersions; import com.zc.component.stratus.beans.ZCObjectVersions.ZCVersionDetail;
copyint maxVersion = 10; Iterable<List<ZCVersionDetail>> paginationIterable=object.listIterableVersions(maxVersion); Iterator<List<ZCVersionDetail>> iterator = paginationIterable.iterator(); while(iterator.hasNext()) { List<ZCVersionDetail> objects= iterator.next(); for(ZCVersionDetail object: objects){ System.out.println(object.getVersionId()); } }
Last Updated 2025-05-30 16:54:59 +0530 +0530
Yes
No
Send your feedback to us
Skip
Submit