ListFileVersions Method
Lists the file versions in a bucket.
Syntax
public func listFileVersions(bucketId: String) throws -> Void
Remarks
This method lists the file versions in the bucket specified by BucketId.
Before calling this method, the Prefix property may be set in order to restrict the results to only the file versions whose names begin with the a given string. The Delimiter property can also be used to further tune the results returned. The MaxResults configuration setting may also be used to limit the number of results returned.
If the currently-authenticated application key is restricted to a specific file name prefix (indicated by the AllowedPrefix property being non-empty), then the Prefix property will automatically be set to that prefix if it is empty when this method is called.
Calling this method will fire the FileList event once for each file version, and will also populate the File* properties. If the ListWithMetadata configuration setting is enabled, the MetadataList event will also be fired, once for each metadata item associated with each file version.
If there are still more files versions available to list when this method returns, the VersionMarker property will be populated. Continue to call this method until VersionMarker is empty to accumulate all pages of results in the File* properties.
The currently-authenticated application key must have the listFiles capability to call this method successfully, otherwise the server will return an error. Refer to the Capabilities property for more information.
File Hierarchy Traversal
By using the Delimiter and Prefix properties in tandem, applications can effectively "traverse" a virtual hierarchy of files (or file versions) as if it were a filesystem. For example, assume that files with the following names exist within a bucket:
- MyCompany
- MyCompany/Department1
- MyCompany/Department2
- MyCompany/Department2/EmployeeA
- MyCompany/Department2/EmployeeB
With Delimiter set to /, we can set Prefix to successively "deeper" values before calling ListFiles or ListFileVersions for the following effect:
Prefix Value | Files Returned | Folders Returned |
(empty) | MyCompany | MyCompany/ |
MyCompany/ | MyCompany/Department1 MyCompany/Department2 | MyCompany/Department2/ |
MyCompany/Department2/ | MyCompany/Department2/EmployeeA MyCompany/Department2/EmployeeB | (none) |