Keyword arguments to pass to the underlying API calls. The following arguments are supported: - if_generation_match - if_generation_not_match - if_metageneration_match - if_metageneration_not_match - timeout - raw_download - single_shot_download Note that download_kwargs (excluding raw_download and single_shot_download) are also applied to blob.reload(), if a reload is needed during seek().
(Optional) The minimum number of bytes to read at a time. If fewer bytes than the chunk_size are requested, the remainder is buffered. The default is the chunk_size of the blob, or 40MiB.
(Optional) How to retry the RPC. A None value will disable retries. A google.api_core.retry.Retry value will enable retries, and the object will define retriable response codes and errors and configure backoff and timeout options. A google.cloud.storage.retry.ConditionalRetryPolicy value wraps a Retry object and activates it only if certain conditions are met. This class exists to provide safe defaults for RPC calls that are not technically safe to retry normally (due to potential data duplication or other side-effects) but become safe to retry if a condition such as if_metageneration_match is set. See the retry.py source code and docstrings in this package (google.cloud.storage.retry) for information on retry types and how to configure them. Media operations (downloads and uploads) do not support non-default predicates in a Retry object. The default will always be used. Other configuration changes for Retry objects such as delays and deadlines are respected.
Methods
close
close()
Flush and close the IO object.
This method has no effect if the file is already closed.
read
read(size=-1)
Read and return up to n bytes.
If the argument is omitted, None, or negative, reads and
returns all data until EOF.
If the argument is positive, and the underlying raw stream is
not 'interactive', multiple raw reads may be issued to satisfy
the byte count (unless EOF is reached first). But for
interactive raw streams (as well as sockets and pipes), at most
one raw read will be issued, and a short result does not imply
that EOF is imminent.
Returns an empty bytes object on EOF.
Returns None if the underlying raw stream was open in non-blocking
mode and no data is available at the moment.
read1
read1(size=-1)
Read and return up to n bytes, with at most one read() call
to the underlying raw stream. A short result does not imply
that EOF is imminent.
Returns an empty bytes object on EOF.
readable
readable()
Return whether object was opened for reading.
If False, read() will raise OSError.
seek
seek(pos,whence=0)
Seek within the blob.
This implementation of seek() uses knowledge of the blob size to
validate that the reported position does not exceed the blob last byte.
If the blob size is not already known it will call blob.reload().
seekable
seekable()
Return whether object supports random access.
If False, seek(), tell() and truncate() will raise OSError.
This method may need to do a test seek().
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Hard to understand","hardToUnderstand","thumb-down"],["Incorrect information or sample code","incorrectInformationOrSampleCode","thumb-down"],["Missing the information/samples I need","missingTheInformationSamplesINeed","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2025-08-12 UTC."],[],[],null,["# Class BlobReader (3.3.0)\n\nVersion latestkeyboard_arrow_down\n\n- [3.3.0 (latest)](/python/docs/reference/storage/latest/google.cloud.storage.fileio.BlobReader)\n- [3.2.0](/python/docs/reference/storage/3.2.0/google.cloud.storage.fileio.BlobReader)\n- [3.1.1](/python/docs/reference/storage/3.1.1/google.cloud.storage.fileio.BlobReader)\n- [3.0.0](/python/docs/reference/storage/3.0.0/google.cloud.storage.fileio.BlobReader)\n- [2.19.0](/python/docs/reference/storage/2.19.0/google.cloud.storage.fileio.BlobReader)\n- [2.17.0](/python/docs/reference/storage/2.17.0/google.cloud.storage.fileio.BlobReader)\n- [2.16.0](/python/docs/reference/storage/2.16.0/google.cloud.storage.fileio.BlobReader)\n- [2.15.0](/python/docs/reference/storage/2.15.0/google.cloud.storage.fileio.BlobReader)\n- [2.14.0](/python/docs/reference/storage/2.14.0/google.cloud.storage.fileio.BlobReader)\n- [2.13.0](/python/docs/reference/storage/2.13.0/google.cloud.storage.fileio.BlobReader)\n- [2.12.0](/python/docs/reference/storage/2.12.0/google.cloud.storage.fileio.BlobReader)\n- [2.11.0](/python/docs/reference/storage/2.11.0/google.cloud.storage.fileio.BlobReader)\n- [2.10.0](/python/docs/reference/storage/2.10.0/google.cloud.storage.fileio.BlobReader)\n- [2.9.0](/python/docs/reference/storage/2.9.0/google.cloud.storage.fileio.BlobReader)\n- [2.8.0](/python/docs/reference/storage/2.8.0/google.cloud.storage.fileio.BlobReader)\n- [2.7.0](/python/docs/reference/storage/2.7.0/google.cloud.storage.fileio.BlobReader)\n- [2.6.0](/python/docs/reference/storage/2.6.0/google.cloud.storage.fileio.BlobReader)\n- [2.5.0](/python/docs/reference/storage/2.5.0/google.cloud.storage.fileio.BlobReader)\n- [2.4.0](/python/docs/reference/storage/2.4.0/google.cloud.storage.fileio.BlobReader)\n- [2.3.0](/python/docs/reference/storage/2.3.0/google.cloud.storage.fileio.BlobReader)\n- [2.2.1](/python/docs/reference/storage/2.2.1/google.cloud.storage.fileio.BlobReader)\n- [2.1.0](/python/docs/reference/storage/2.1.0/google.cloud.storage.fileio.BlobReader)\n- [2.0.0](/python/docs/reference/storage/2.0.0/google.cloud.storage.fileio.BlobReader)\n- [1.44.0](/python/docs/reference/storage/1.44.0/google.cloud.storage.fileio.BlobReader)\n- [1.43.0](/python/docs/reference/storage/1.43.0/google.cloud.storage.fileio.BlobReader)\n- [1.42.3](/python/docs/reference/storage/1.42.3/google.cloud.storage.fileio.BlobReader)\n- [1.41.1](/python/docs/reference/storage/1.41.1/google.cloud.storage.fileio.BlobReader)\n- [1.40.0](/python/docs/reference/storage/1.40.0/google.cloud.storage.fileio.BlobReader)\n- [1.39.0](/python/docs/reference/storage/1.39.0/google.cloud.storage.fileio.BlobReader)\n- [1.38.0](/python/docs/reference/storage/1.38.0/google.cloud.storage.fileio.BlobReader)\n- [1.37.1](/python/docs/reference/storage/1.37.1/google.cloud.storage.fileio.BlobReader)\n- [1.36.2](/python/docs/reference/storage/1.36.2/google.cloud.storage.fileio.BlobReader)\n- [1.35.1](/python/docs/reference/storage/1.35.1/google.cloud.storage.fileio.BlobReader)\n- [1.34.0](/python/docs/reference/storage/1.34.0/google.cloud.storage.fileio.BlobReader)\n- [1.33.0](/python/docs/reference/storage/1.33.0/google.cloud.storage.fileio.BlobReader)\n- [1.32.0](/python/docs/reference/storage/1.32.0/google.cloud.storage.fileio.BlobReader)\n- [1.31.2](/python/docs/reference/storage/1.31.2/google.cloud.storage.fileio.BlobReader)\n- [1.30.0](/python/docs/reference/storage/1.30.0/google.cloud.storage.fileio.BlobReader)\n- [1.29.0](/python/docs/reference/storage/1.29.0/google.cloud.storage.fileio.BlobReader)\n- [1.28.1](/python/docs/reference/storage/1.28.1/google.cloud.storage.fileio.BlobReader)\n- [1.27.0](/python/docs/reference/storage/1.27.0/google.cloud.storage.fileio.BlobReader)\n- [1.26.0](/python/docs/reference/storage/1.26.0/google.cloud.storage.fileio.BlobReader)\n- [1.25.0](/python/docs/reference/storage/1.25.0/google.cloud.storage.fileio.BlobReader)\n- [1.24.1](/python/docs/reference/storage/1.24.1/google.cloud.storage.fileio.BlobReader)\n- [1.23.0](/python/docs/reference/storage/1.23.0/google.cloud.storage.fileio.BlobReader)\n- [1.22.0](/python/docs/reference/storage/1.22.0/google.cloud.storage.fileio.BlobReader)\n- [1.21.0](/python/docs/reference/storage/1.21.0/google.cloud.storage.fileio.BlobReader)\n- [1.20.0](/python/docs/reference/storage/1.20.0/google.cloud.storage.fileio.BlobReader)\n- [1.19.0](/python/docs/reference/storage/1.19.0/google.cloud.storage.fileio.BlobReader)\n- [1.18.0](/python/docs/reference/storage/1.18.0/google.cloud.storage.fileio.BlobReader)\n- [1.17.0](/python/docs/reference/storage/1.17.0/google.cloud.storage.fileio.BlobReader) \n\n BlobReader(blob, chunk_size=None, retry=\u003cgoogle.api_core.retry.retry_unary.Retry object\u003e, **download_kwargs)\n\nA file-like object that reads from a blob.\n\nMethods\n-------\n\n### close\n\n close()\n\nFlush and close the IO object.\n\nThis method has no effect if the file is already closed.\n\n### read\n\n read(size=-1)\n\nRead and return up to n bytes.\n\nIf the argument is omitted, None, or negative, reads and\nreturns all data until EOF.\n\nIf the argument is positive, and the underlying raw stream is\nnot 'interactive', multiple raw reads may be issued to satisfy\nthe byte count (unless EOF is reached first). But for\ninteractive raw streams (as well as sockets and pipes), at most\none raw read will be issued, and a short result does not imply\nthat EOF is imminent.\n\nReturns an empty bytes object on EOF.\n\nReturns None if the underlying raw stream was open in non-blocking\nmode and no data is available at the moment.\n\n### read1\n\n read1(size=-1)\n\nRead and return up to n bytes, with at most one read() call\nto the underlying raw stream. A short result does not imply\nthat EOF is imminent.\n\nReturns an empty bytes object on EOF.\n\n### readable\n\n readable()\n\nReturn whether object was opened for reading.\n\nIf False, read() will raise OSError.\n\n### seek\n\n seek(pos, whence=0)\n\nSeek within the blob.\n\nThis implementation of seek() uses knowledge of the blob size to\nvalidate that the reported position does not exceed the blob last byte.\nIf the blob size is not already known it will call blob.reload().\n\n### seekable\n\n seekable()\n\nReturn whether object supports random access.\n\nIf False, seek(), tell() and truncate() will raise OSError.\nThis method may need to do a test seek().\n\n### writable\n\n writable()\n\nReturn whether object was opened for writing.\n\nIf False, write() will raise OSError."]]