Cloud Storage Client - Class ReadStream (1.49.2) Stay organized with collections Save and categorize content based on your preferences.
Reference documentation and code samples for the Cloud Storage Client class ReadStream.
A Stream implementation that wraps a GuzzleHttp download stream toprovidegetSize() from the response headers.
Namespace
Google \ Cloud \ StorageMethods
__construct
Create a new ReadStream.
| Parameter | |
|---|---|
| Name | Description |
stream | Psr\Http\Message\StreamInterfaceThe stream interface to wrap |
getSize
Return the full size of the buffer. If the underlying stream doesnot report it's size, try to fetch the size from the Content-Lengthresponse header.
| Returns | |
|---|---|
| Type | Description |
int | The size of the stream. |
read
Read bytes from the underlying buffer, retrying until we have readenough bytes or we cannot read any more. We do this because theinternal C code for filling a buffer does not account for whenwe try to read large chunks from a user-land stream that does notreturn enough bytes.
| Parameter | |
|---|---|
| Name | Description |
length | intThe number of bytes to read. |
| Returns | |
|---|---|
| Type | Description |
string | Read bytes from the underlying stream. |
Except as otherwise noted, the content of this page is licensed under theCreative Commons Attribution 4.0 License, and code samples are licensed under theApache 2.0 License. For details, see theGoogle Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.
Last updated 2026-01-24 UTC.