list_blobs Method
Lists the blobs in a container.
Syntax
def list_blobs() -> None: ...
Remarks
This method lists the blobs in the container currently selected by container.
Before calling this method, the prefix property may be set in order to restrict the results to only the items whose names begin with a given string. The MaxResults configuration setting may also be used to limit the number of results returned. The following properties and configuration settings can also be used to further tune the results returned; refer to their documentation for more information:
Calling this method will fire the on_blob_list event once for each blob, and will also populate the Blob* properties. It may also fire the on_prefix_list and on_metadata_list events, and populate the PrefixCount and Prefix[i] configuration settings, depending on how the properties and configuration settings discussed above are set.
If there are still more blobs available to list when this method returns, the blob_marker property will be populated. Continue to call this method until blob_marker is empty to accumulate all pages of results in the Blob* properties.
Blob Namespace Traversal
By using the blob_delimiter and prefix properties in tandem, applications can effectively "traverse" a virtual hierarchy of blobs as if it were a filesystem. For example, assume that blobs with the following names exist within a container:
- MyCompany
- MyCompany/Department1
- MyCompany/Department2
- MyCompany/Department2/EmployeeA
- MyCompany/Department2/EmployeeB
With blob_delimiter set to /, we can set prefix to successively "deeper" values before calling list_blobs for the following effect:
prefix Value | Blobs Returned | Prefixes Returned |
(empty) | MyCompany | MyCompany/ |
MyCompany/ | MyCompany/Department1 MyCompany/Department2 | MyCompany/Department2/ |
MyCompany/Department2/ | MyCompany/Department2/EmployeeA MyCompany/Department2/EmployeeB | (none) |