Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 03280fa

Browse filesBrowse files
authored
Update list blobs to use new client.list_blobs() method. (GoogleCloudPlatform#2296)
* Update list blob samples * Update requirements.txt * Fix lint issues * Use latest storage client
1 parent 09f7eb4 commit 03280fa
Copy full SHA for 03280fa

File tree

Expand file treeCollapse file tree

2 files changed

+4
-7
lines changed
Filter options
Expand file treeCollapse file tree

2 files changed

+4
-7
lines changed

‎storage/cloud-client/requirements.txt

Copy file name to clipboard
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
google-cloud-pubsub==0.39.1
2-
google-cloud-storage==1.15.0
2+
google-cloud-storage==1.17.0

‎storage/cloud-client/snippets.py

Copy file name to clipboardExpand all lines: storage/cloud-client/snippets.py
+3-6Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -113,9 +113,7 @@ def list_buckets():
113113
def list_blobs(bucket_name):
114114
"""Lists all the blobs in the bucket."""
115115
storage_client = storage.Client()
116-
bucket = storage_client.get_bucket(bucket_name)
117-
118-
blobs = bucket.list_blobs()
116+
blobs = storage_client.list_blobs(bucket_name)
119117

120118
for blob in blobs:
121119
print(blob.name)
@@ -144,9 +142,8 @@ def list_blobs_with_prefix(bucket_name, prefix, delimiter=None):
144142
145143
"""
146144
storage_client = storage.Client()
147-
bucket = storage_client.get_bucket(bucket_name)
148-
149-
blobs = bucket.list_blobs(prefix=prefix, delimiter=delimiter)
145+
blobs = storage_client.list_blobs(bucket_name, prefix=prefix,
146+
delimiter=delimiter)
150147

151148
print('Blobs:')
152149
for blob in blobs:

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.