Skip to content

Update list blobs to use new client.list_blobs() method. #2296

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

Merged
merged 5 commits into from
Jul 24, 2019
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
2 changes: 1 addition & 1 deletion storage/cloud-client/requirements.txt
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
google-cloud-pubsub==0.39.1
google-cloud-storage==1.15.0
google-cloud-storage==1.17.0
9 changes: 3 additions & 6 deletions storage/cloud-client/snippets.py
Original file line number Diff line number Diff line change
Expand Up @@ -113,9 +113,7 @@ def list_buckets():
def list_blobs(bucket_name):
"""Lists all the blobs in the bucket."""
storage_client = storage.Client()
bucket = storage_client.get_bucket(bucket_name)

blobs = bucket.list_blobs()
blobs = storage_client.list_blobs(bucket_name)

for blob in blobs:
print(blob.name)
Expand Down Expand Up @@ -144,9 +142,8 @@ def list_blobs_with_prefix(bucket_name, prefix, delimiter=None):

"""
storage_client = storage.Client()
bucket = storage_client.get_bucket(bucket_name)

blobs = bucket.list_blobs(prefix=prefix, delimiter=delimiter)
blobs = storage_client.list_blobs(bucket_name, prefix=prefix,
delimiter=delimiter)

print('Blobs:')
for blob in blobs:
Expand Down