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 c55cd88

Browse filesBrowse files
authored
fix: add a comment to draw attention to using get_blob, not blob (GoogleCloudPlatform#5052)
* fix: add a comment to draw attention to using get_blob, not blob * docs: further elaboration * docs: add clarifying doc string to download file * Update storage_download_file.py * Update storage_download_file.py
1 parent 1dc223b commit c55cd88
Copy full SHA for c55cd88

File tree

Expand file treeCollapse file tree

2 files changed

+9
-0
lines changed
Filter options
Expand file treeCollapse file tree

2 files changed

+9
-0
lines changed

‎storage/cloud-client/storage_download_file.py

Copy file name to clipboardExpand all lines: storage/cloud-client/storage_download_file.py
+5Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,11 @@ def download_blob(bucket_name, source_blob_name, destination_file_name):
2929
storage_client = storage.Client()
3030

3131
bucket = storage_client.bucket(bucket_name)
32+
33+
# Construct a client side representation of a blob.
34+
# Note `Bucket.blob` differs from `Bucket.get_blob` as it doesn't retrieve
35+
# any content from Google Cloud Storage. As we don't need additional data,
36+
# using `Bucket.blob` is preferred here.
3237
blob = bucket.blob(source_blob_name)
3338
blob.download_to_filename(destination_file_name)
3439

‎storage/cloud-client/storage_get_metadata.py

Copy file name to clipboardExpand all lines: storage/cloud-client/storage_get_metadata.py
+4Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,10 @@ def blob_metadata(bucket_name, blob_name):
2727

2828
storage_client = storage.Client()
2929
bucket = storage_client.bucket(bucket_name)
30+
31+
# Retrieve a blob, and its metadata, from Google Cloud Storage.
32+
# Note that `get_blob` differs from `Bucket.blob`, which does not
33+
# make an HTTP request.
3034
blob = bucket.get_blob(blob_name)
3135

3236
print("Blob: {}".format(blob.name))

0 commit comments

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