You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Mar 31, 2026. It is now read-only.
>>> with open('file-to-download-to', 'w') as file_obj:
>>> client.download_blob_to_file(blob, file_obj) # API request.
Download a blob using a URI.
>>> from google.cloud import storage
>>> client = storage.Client()
>>> with open('file-to-download-to', 'w') as file_obj:
>>> client.download_blob_to_file(
>>> 'gs://bucket_name/path/to/blob', file_obj)
Stack trace
Traceback (most recent call last):
File "{file}", line 14, in <module>
storage_client.download_blob_to_file(uri, file_obj)
File "{working dir}/.va/lib/python3.10/site-packages/google/cloud/storage/client.py", line 1128, in download_blob_to_file
blob_or_uri._do_download(
File "{working dir}/.va/lib/python3.10/site-packages/google/cloud/storage/blob.py", line 1000, in _do_download
response = download.consume(transport, timeout=timeout)
File "{working dir}/.va/lib/python3.10/site-packages/google/resumable_media/requests/download.py", line 174, in consume
return _request_helpers.wait_and_retry(
File "{working dir}/.va/lib/python3.10/site-packages/google/resumable_media/requests/_request_helpers.py", line 147, in wait_and_retry
response = func()
File "{working dir}/.va/lib/python3.10/site-packages/google/resumable_media/requests/download.py", line 170, in retriable_request
self._write_to_stream(result)
File "{working dir}/.va/lib/python3.10/site-packages/google/resumable_media/requests/download.py", line 106, in _write_to_stream
self._stream.write(chunk)
TypeError: write() argument must be str, not bytes
download_blob_to_file()example does not working. When I change'w'to'bw'inopen(), that is working. Please check this bug.Environment details
python --version: 3.10.2pip --version: 21.3.1google-cloud-storageversion:pip show google-cloud-storage: 2.1.0Code example
Reference:
python-storage/google/cloud/storage/client.py
Lines 1074 to 1094 in 192fe9c
Stack trace