Reference documentation and code samples for the Cloud Storage Client class ReadStream.
A Stream implementation that wraps a GuzzleHttp download stream to
provide getSize() from the response headers.
Namespace
Google \ Cloud \ Storage
Methods
__construct
Create a new ReadStream.
Parameter
Name
Description
stream
Psr\Http\Message\StreamInterface
The stream interface to wrap
getSize
Return the full size of the buffer. If the underlying stream does
not report it's size, try to fetch the size from the Content-Length
response header.
Returns
Type
Description
int
The size of the stream.
read
Read bytes from the underlying buffer, retrying until we have read
enough bytes or we cannot read any more. We do this because the
internal C code for filling a buffer does not account for when
we try to read large chunks from a user-land stream that does not
return enough bytes.
[[["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-09-04 UTC."],[],[],null,["# Cloud Storage Client - Class ReadStream (1.48.3)\n\nVersion latestkeyboard_arrow_down\n\n- [1.48.3 (latest)](/php/docs/reference/cloud-storage/latest/ReadStream)\n- [1.48.2](/php/docs/reference/cloud-storage/1.48.2/ReadStream)\n- [1.47.0](/php/docs/reference/cloud-storage/1.47.0/ReadStream)\n- [1.46.0](/php/docs/reference/cloud-storage/1.46.0/ReadStream)\n- [1.45.0](/php/docs/reference/cloud-storage/1.45.0/ReadStream)\n- [1.44.0](/php/docs/reference/cloud-storage/1.44.0/ReadStream)\n- [1.43.1](/php/docs/reference/cloud-storage/1.43.1/ReadStream)\n- [1.42.1](/php/docs/reference/cloud-storage/1.42.1/ReadStream)\n- [1.41.4](/php/docs/reference/cloud-storage/1.41.4/ReadStream)\n- [1.37.0](/php/docs/reference/cloud-storage/1.37.0/ReadStream)\n- [1.36.1](/php/docs/reference/cloud-storage/1.36.1/ReadStream)\n- [1.35.0](/php/docs/reference/cloud-storage/1.35.0/ReadStream)\n- [1.34.0](/php/docs/reference/cloud-storage/1.34.0/ReadStream)\n- [1.33.4](/php/docs/reference/cloud-storage/1.33.4/ReadStream)\n- [1.32.0](/php/docs/reference/cloud-storage/1.32.0/ReadStream)\n- [1.31.2](/php/docs/reference/cloud-storage/1.31.2/ReadStream)\n- [1.30.3](/php/docs/reference/cloud-storage/1.30.3/ReadStream) \nReference documentation and code samples for the Cloud Storage Client class ReadStream.\n\nA Stream implementation that wraps a GuzzleHttp download stream to\nprovide `getSize()` from the response headers.\n\nNamespace\n---------\n\nGoogle \\\\ Cloud \\\\ Storage\n\nMethods\n-------\n\n### __construct\n\nCreate a new ReadStream.\n\n### getSize\n\nReturn the full size of the buffer. If the underlying stream does\nnot report it's size, try to fetch the size from the Content-Length\nresponse header.\n\n### read\n\nRead bytes from the underlying buffer, retrying until we have read\nenough bytes or we cannot read any more. We do this because the\ninternal C code for filling a buffer does not account for when\nwe try to read large chunks from a user-land stream that does not\nreturn enough bytes."]]