Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

docs: clarify list_blobs usage #866

Merged
merged 1 commit into from
Sep 15, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion google/cloud/storage/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -1269,7 +1269,8 @@ def list_blobs(

Returns:
Iterator of all :class:`~google.cloud.storage.blob.Blob`
in this bucket matching the arguments.
in this bucket matching the arguments. The RPC call
returns a response when the iterator is consumed.

As part of the response, you'll also get back an iterator.prefixes entity that lists object names
up to and including the requested delimiter. Duplicate entries are omitted from this list.
Expand Down
1 change: 1 addition & 0 deletions samples/snippets/storage_list_files.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ def list_blobs(bucket_name):
# Note: Client.list_blobs requires at least package version 1.17.0.
blobs = storage_client.list_blobs(bucket_name)

# Note: The call returns a response only when the iterator is consumed.
for blob in blobs:
print(blob.name)

Expand Down
1 change: 1 addition & 0 deletions samples/snippets/storage_list_files_with_prefix.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ def list_blobs_with_prefix(bucket_name, prefix, delimiter=None):
# Note: Client.list_blobs requires at least package version 1.17.0.
blobs = storage_client.list_blobs(bucket_name, prefix=prefix, delimiter=delimiter)

# Note: The call returns a response only when the iterator is consumed.
print("Blobs:")
for blob in blobs:
print(blob.name)
Expand Down