# uploadPieces

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

Defined in: [packages/synapse-core/src/sp/upload-pieces.ts:80](https://github.com/FilOzone/synapse-sdk/blob/628d3a8812e8612a183a3abe3328169fb741260b/packages/synapse-core/src/sp/upload-pieces.ts#L80)

Upload pieces to an existing data set and add them in one signed request.

Streams each piece to the data set's provider (`concurrency` at a time), then adds every parked piece in one
add-pieces request and waits for it to be confirmed. Pieces that fail to upload, or whose add-pieces transaction is
not confirmed, are returned in `failed`; the others are still added. Throws when no piece could be uploaded and added.

## Parameters

| Parameter | Type | Description |
| ------ | ------ | ------ |
| `client` | `Client`\<`Transport`, `Chain`, `Account`\> | The client to sign with. |
| `options` | [`OptionsType`](/reference/filoz/synapse-core/sp/namespaces/uploadpieces/type-aliases/optionstype/) | [uploadPieces.OptionsType](/reference/filoz/synapse-core/sp/namespaces/uploadpieces/type-aliases/optionstype/) |

## Returns

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

The confirmations, the added pieces and the failed ones. [uploadPieces.OutputType](/reference/filoz/synapse-core/sp/namespaces/uploadpieces/type-aliases/outputtype/)

## Example

```ts
import * as SP from '@filoz/synapse-core/sp'

const { pieces, failed } = await SP.uploadPieces(client, {
  dataSet,
  pieces: files.map((file) => ({ data: file, metadata: { name: file.name } })),
})
```