# Cloud Storage Client - Class WriteStream (2.3.0)

2.3.0 (latest) 2.2.0 2.1.0 2.0.0 1.51.0 1.50.0 1.49.2 1.48.7 1.47.0 1.46.0 1.45.0 1.44.0 1.43.1 1.42.1 1.41.4 1.37.0 1.36.1 1.35.0 1.34.0 1.33.4 1.32.0 1.31.2 1.30.3 Reference documentation and code samples for the Cloud Storage Client class WriteStream.

A Stream implementation that uploads in chunks to a provided uploader when
we reach a certain chunkSize. Upon `close`, we will upload the remaining chunk.

## Namespace

Google \\ Cloud \\ Storage

## Methods

### __construct

Create a new WriteStream instance

| **Parameters** ||
|---|---|
| **Name** | **Description** |
| `uploader` | `https://docs.cloud.google.com/php/docs/reference/cloud-core/latest/Upload.AbstractUploader.html` The uploader to use. |
| `options` | `array` Configuration options. |
| `↳ chunkSize` | `int` The size of the buffer above which we attempt to upload data |

### close

Close the stream. Uploads any remaining data.

### write

Write to the stream. If we pass the chunkable size, upload the available chunk.

| **Parameter** ||
|---|---|
| **Name** | **Description** |
| `data` | `string` Data to write |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `int` | The number of bytes written |

### setUploader

Set the uploader for this class. You may need to set this after initialization
if the uploader depends on this stream.

| **Parameter** ||
|---|---|
| **Name** | **Description** |
| `uploader` | `https://docs.cloud.google.com/php/docs/reference/cloud-core/latest/Upload.AbstractUploader.html` The new uploader to use. |