Skip to content

Commit

Permalink
samples: replace deprecated method (#1211)
Browse files Browse the repository at this point in the history
* samples: replace deprecated method

* update print statement, decode
  • Loading branch information
cojenco authored Feb 28, 2024
1 parent ae9a53b commit 0b8f5b0
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
4 changes: 2 additions & 2 deletions samples/snippets/snippets_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -361,7 +361,7 @@ def test_generate_upload_signed_url_v4(test_bucket, capsys):

bucket = storage.Client().bucket(test_bucket.name)
blob = bucket.blob(blob_name)
assert blob.download_as_string() == content
assert blob.download_as_bytes() == content


def test_generate_signed_policy_v4(test_bucket, capsys):
Expand Down Expand Up @@ -592,7 +592,7 @@ def test_storage_compose_file(test_bucket):
source_files[1],
dest_file.name,
)
composed = destination.download_as_string()
composed = destination.download_as_bytes()

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

Expand Down
6 changes: 3 additions & 3 deletions samples/snippets/storage_download_into_memory.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,11 +37,11 @@ def download_blob_into_memory(bucket_name, blob_name):
# any content from Google Cloud Storage. As we don't need additional data,
# using `Bucket.blob` is preferred here.
blob = bucket.blob(blob_name)
contents = blob.download_as_string()
contents = blob.download_as_bytes()

print(
"Downloaded storage object {} from bucket {} as the following string: {}.".format(
blob_name, bucket_name, contents
"Downloaded storage object {} from bucket {} as the following bytes object: {}.".format(
blob_name, bucket_name, contents.decode("utf-8")
)
)

Expand Down

0 comments on commit 0b8f5b0

Please sign in to comment.