# createPieceCIDStream

```ts
function createPieceCIDStream(): object;
```

Defined in: [packages/synapse-core/src/piece.ts:313](https://github.com/FilOzone/synapse-sdk/blob/1d6c4b9fe34534bf1087dfe41491b72be0b46858/packages/synapse-core/src/piece.ts#L313)

Create a TransformStream that calculates PieceCID while streaming data through it
This allows calculating PieceCID without buffering the entire data in memory

## Returns

`object`

An object with the TransformStream and a getPieceCID function to retrieve the result

### getPieceCID()

```ts
getPieceCID: () => PieceLink | null;
```

#### Returns

`PieceLink` \| `null`

### stream

```ts
stream: TransformStream<Uint8Array<ArrayBufferLike>, Uint8Array<ArrayBufferLike>>;
```

## Example

```ts
const { stream, getPieceCID } = createPieceCIDStream()
await fetch(url, {
  method: 'PUT',
  body: dataStream.pipeThrough(stream)
})
const pieceCid = getPieceCID() // Available after stream completes
```