Skip to content

Commit 0b8f5b0

Browse files
authored
samples: replace deprecated method (#1211)
* samples: replace deprecated method * update print statement, decode
1 parent ae9a53b commit 0b8f5b0

File tree

2 files changed

+5
-5
lines changed

2 files changed

+5
-5
lines changed

samples/snippets/snippets_test.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -361,7 +361,7 @@ def test_generate_upload_signed_url_v4(test_bucket, capsys):
361361

362362
bucket = storage.Client().bucket(test_bucket.name)
363363
blob = bucket.blob(blob_name)
364-
assert blob.download_as_string() == content
364+
assert blob.download_as_bytes() == content
365365

366366

367367
def test_generate_signed_policy_v4(test_bucket, capsys):
@@ -592,7 +592,7 @@ def test_storage_compose_file(test_bucket):
592592
source_files[1],
593593
dest_file.name,
594594
)
595-
composed = destination.download_as_string()
595+
composed = destination.download_as_bytes()
596596

597597
assert composed.decode("utf-8") == source_files[0] + source_files[1]
598598

samples/snippets/storage_download_into_memory.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,11 +37,11 @@ def download_blob_into_memory(bucket_name, blob_name):
3737
# any content from Google Cloud Storage. As we don't need additional data,
3838
# using `Bucket.blob` is preferred here.
3939
blob = bucket.blob(blob_name)
40-
contents = blob.download_as_string()
40+
contents = blob.download_as_bytes()
4141

4242
print(
43-
"Downloaded storage object {} from bucket {} as the following string: {}.".format(
44-
blob_name, bucket_name, contents
43+
"Downloaded storage object {} from bucket {} as the following bytes object: {}.".format(
44+
blob_name, bucket_name, contents.decode("utf-8")
4545
)
4646
)
4747

0 commit comments

Comments
 (0)