# uploadPieceStreaming

> **uploadPieceStreaming**(`options`): [`Promise`](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)\<[`OutputType`](/reference/filoz/synapse-core/sp/namespaces/uploadpiecestreaming/type-aliases/outputtype/)\>

Defined in: [packages/synapse-core/src/sp/upload-streaming.ts:100](https://github.com/FilOzone/synapse-sdk/blob/840d7b2c6263846ac51b7558000e62dd68d33a44/packages/synapse-core/src/sp/upload-streaming.ts#L100)

Upload piece data using the 3-step CommP-last streaming protocol.

Protocol:
1. POST /pdp/piece/uploads → get upload session UUID
2. PUT /pdp/piece/uploads/{uuid} → stream data while calculating CommP
3. POST /pdp/piece/uploads/{uuid} → finalize with calculated CommP
4. With `waitForParked`, GET /pdp/piece?pieceCid={pieceCid} until the piece is parked

## Parameters

| Parameter | Type | Description |
| ------ | ------ | ------ |
| `options` | [`OptionsType`](/reference/filoz/synapse-core/sp/namespaces/uploadpiecestreaming/type-aliases/optionstype/) | [uploadPieceStreaming.OptionsType](/reference/filoz/synapse-core/sp/namespaces/uploadpiecestreaming/type-aliases/optionstype/) |

## Returns

[`Promise`](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)\<[`OutputType`](/reference/filoz/synapse-core/sp/namespaces/uploadpiecestreaming/type-aliases/outputtype/)\>

PieceCID and size of uploaded data [uploadPieceStreaming.OutputType](/reference/filoz/synapse-core/sp/namespaces/uploadpiecestreaming/type-aliases/outputtype/)

## Example

```ts
import { createReadStream } from 'node:fs'
import * as SP from '@filoz/synapse-core/sp'

const { pieceCid, size } = await SP.uploadPieceStreaming({
  serviceURL: 'https://pdp.example.com',
  data: createReadStream('./file.bin'),
  waitForParked: true,
})
```

## Throws

Errors [uploadPieceStreaming.ErrorType](/reference/filoz/synapse-core/sp/namespaces/uploadpiecestreaming/type-aliases/errortype/)