# StorageManager

Defined in: [packages/synapse-sdk/src/storage/manager.ts:121](https://github.com/FilOzone/synapse-sdk/blob/83770aa3b42e40c80326c80cbbbd1c1206c920c0/packages/synapse-sdk/src/storage/manager.ts#L121)

## Constructors

### Constructor

> **new StorageManager**(`options`): `StorageManager`

Defined in: [packages/synapse-sdk/src/storage/manager.ts:131](https://github.com/FilOzone/synapse-sdk/blob/83770aa3b42e40c80326c80cbbbd1c1206c920c0/packages/synapse-sdk/src/storage/manager.ts#L131)

Creates a new StorageManager

#### Parameters

| Parameter | Type | Description |
| ------ | ------ | ------ |
| `options` | [`StorageManagerOptions`](/reference/filoz/synapse-sdk/storage/interfaces/storagemanageroptions/) | The options for the StorageManager [StorageManagerOptions](/reference/filoz/synapse-sdk/storage/interfaces/storagemanageroptions/) |

#### Returns

`StorageManager`

## Methods

### createContext()

> **createContext**(`options?`): [`Promise`](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)\<[`StorageContext`](/reference/filoz/synapse-sdk/storage/classes/storagecontext/)\>

Defined in: [packages/synapse-sdk/src/storage/manager.ts:680](https://github.com/FilOzone/synapse-sdk/blob/83770aa3b42e40c80326c80cbbbd1c1206c920c0/packages/synapse-sdk/src/storage/manager.ts#L680)

Create a single storage context with specified options

#### Parameters

| Parameter | Type |
| ------ | ------ |
| `options?` | [`StorageServiceOptions`](/reference/filoz/synapse-sdk/synapse/interfaces/storageserviceoptions/) |

#### Returns

[`Promise`](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)\<[`StorageContext`](/reference/filoz/synapse-sdk/storage/classes/storagecontext/)\>

***

### createContexts()

> **createContexts**(`options?`): [`Promise`](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)\<[`StorageContext`](/reference/filoz/synapse-sdk/storage/classes/storagecontext/)[]\>

Defined in: [packages/synapse-sdk/src/storage/manager.ts:623](https://github.com/FilOzone/synapse-sdk/blob/83770aa3b42e40c80326c80cbbbd1c1206c920c0/packages/synapse-sdk/src/storage/manager.ts#L623)

Creates storage contexts for multi-provider storage deals and other operations.

By storing data with multiple independent providers, you reduce dependency on any
single provider and improve overall data availability. Use contexts together as a group.

Contexts are selected by priority:
1. Specified datasets (`dataSetIds`) - uses their existing providers
2. Specified providers (`providerIds`) - finds or creates matching datasets
3. Automatically selected from remaining approved providers

For automatic selection, existing datasets matching the `metadata` are reused.
Providers are randomly chosen to distribute across the network.

#### Parameters

| Parameter | Type | Description |
| ------ | ------ | ------ |
| `options?` | [`CreateContextsOptions`](/reference/filoz/synapse-sdk/synapse/interfaces/createcontextsoptions/) | Configuration options [CreateContextsOptions](/reference/filoz/synapse-sdk/synapse/interfaces/createcontextsoptions/) |

#### Returns

[`Promise`](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)\<[`StorageContext`](/reference/filoz/synapse-sdk/storage/classes/storagecontext/)[]\>

Promise resolving to array of storage contexts

***

### download()

> **download**(`options`): [`Promise`](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)\<[`Uint8Array`](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Uint8Array)\<`ArrayBufferLike`\>\>

Defined in: [packages/synapse-sdk/src/storage/manager.ts:499](https://github.com/FilOzone/synapse-sdk/blob/83770aa3b42e40c80326c80cbbbd1c1206c920c0/packages/synapse-sdk/src/storage/manager.ts#L499)

Download data from storage
If context is provided, routes to context.download()
Otherwise performs SP-agnostic download

#### Parameters

| Parameter | Type |
| ------ | ------ |
| `options` | [`StorageManagerDownloadOptions`](/reference/filoz/synapse-sdk/storage/interfaces/storagemanagerdownloadoptions/) |

#### Returns

[`Promise`](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)\<[`Uint8Array`](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Uint8Array)\<`ArrayBufferLike`\>\>

***

### findDataSets()

> **findDataSets**(`options?`): [`Promise`](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)\<[`EnhancedDataSetInfo`](/reference/filoz/synapse-sdk/synapse/interfaces/enhanceddatasetinfo/)[]\>

Defined in: [packages/synapse-sdk/src/storage/manager.ts:752](https://github.com/FilOzone/synapse-sdk/blob/83770aa3b42e40c80326c80cbbbd1c1206c920c0/packages/synapse-sdk/src/storage/manager.ts#L752)

Query data sets for this client

#### Parameters

| Parameter | Type | Description |
| ------ | ------ | ------ |
| `options` | \{ `address?`: `` `0x${string}` ``; \} | The options for the find data sets |
| `options.address?` | `` `0x${string}` `` | The client address, defaults to current signer |

#### Returns

[`Promise`](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)\<[`EnhancedDataSetInfo`](/reference/filoz/synapse-sdk/synapse/interfaces/enhanceddatasetinfo/)[]\>

Array of enhanced data set information including management status

***

### getDefaultContext()

> **getDefaultContext**(): [`Promise`](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)\<[`StorageContext`](/reference/filoz/synapse-sdk/storage/classes/storagecontext/)\>

Defined in: [packages/synapse-sdk/src/storage/manager.ts:742](https://github.com/FilOzone/synapse-sdk/blob/83770aa3b42e40c80326c80cbbbd1c1206c920c0/packages/synapse-sdk/src/storage/manager.ts#L742)

Get or create the default context

#### Returns

[`Promise`](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)\<[`StorageContext`](/reference/filoz/synapse-sdk/storage/classes/storagecontext/)\>

***

### getStorageInfo()

> **getStorageInfo**(): [`Promise`](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)\<[`StorageInfo`](/reference/filoz/synapse-sdk/synapse/interfaces/storageinfo/)\>

Defined in: [packages/synapse-sdk/src/storage/manager.ts:773](https://github.com/FilOzone/synapse-sdk/blob/83770aa3b42e40c80326c80cbbbd1c1206c920c0/packages/synapse-sdk/src/storage/manager.ts#L773)

Get comprehensive information about the storage service including
approved providers, pricing, contract addresses, and current allowances

#### Returns

[`Promise`](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)\<[`StorageInfo`](/reference/filoz/synapse-sdk/synapse/interfaces/storageinfo/)\>

Complete storage service information

***

### preflightUpload()

> **preflightUpload**(`options`): [`Promise`](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)\<[`PreflightInfo`](/reference/filoz/synapse-sdk/synapse/interfaces/preflightinfo/)\>

Defined in: [packages/synapse-sdk/src/storage/manager.ts:574](https://github.com/FilOzone/synapse-sdk/blob/83770aa3b42e40c80326c80cbbbd1c1206c920c0/packages/synapse-sdk/src/storage/manager.ts#L574)

Run preflight checks for an upload without creating a context

#### Parameters

| Parameter | Type | Description |
| ------ | ------ | ------ |
| `options` | \{ `metadata?`: [`Record`](https://www.typescriptlang.org/docs/handbook/utility-types.html#recordkeys-type)\<`string`, `string`\>; `size`: `number`; `withCDN?`: `boolean`; \} | The options for the preflight upload |
| `options.metadata?` | [`Record`](https://www.typescriptlang.org/docs/handbook/utility-types.html#recordkeys-type)\<`string`, `string`\> | The metadata for the preflight upload |
| `options.size` | `number` | The size of data to upload in bytes |
| `options.withCDN?` | `boolean` | Whether to enable CDN services |

#### Returns

[`Promise`](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)\<[`PreflightInfo`](/reference/filoz/synapse-sdk/synapse/interfaces/preflightinfo/)\>

Preflight information including costs and allowances

***

### terminateDataSet()

> **terminateDataSet**(`options`): [`Promise`](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)\<`` `0x${string}` ``\>

Defined in: [packages/synapse-sdk/src/storage/manager.ts:764](https://github.com/FilOzone/synapse-sdk/blob/83770aa3b42e40c80326c80cbbbd1c1206c920c0/packages/synapse-sdk/src/storage/manager.ts#L764)

Terminate a data set with given ID that belongs to the synapse signer.
This will also result in the removal of all pieces in the data set.

#### Parameters

| Parameter | Type | Description |
| ------ | ------ | ------ |
| `options` | \{ `dataSetId`: `bigint`; \} | The options for the terminate data set |
| `options.dataSetId` | `bigint` | The ID of the data set to terminate |

#### Returns

[`Promise`](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)\<`` `0x${string}` ``\>

Transaction hash

***

### upload()

> **upload**(`data`, `options?`): [`Promise`](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)\<[`UploadResult`](/reference/filoz/synapse-sdk/synapse/interfaces/uploadresult/)\>

Defined in: [packages/synapse-sdk/src/storage/manager.ts:160](https://github.com/FilOzone/synapse-sdk/blob/83770aa3b42e40c80326c80cbbbd1c1206c920c0/packages/synapse-sdk/src/storage/manager.ts#L160)

Upload data to Filecoin Onchain Cloud using a store->pull->commit flow across
multiple providers.

By default, uploads to 2 providers (primary + secondary) for redundancy.
Data is uploaded once to the primary, then secondaries pull from the primary
via SP-to-SP transfer.

This method only throws if zero copies succeed. Individual copy failures
are recorded in `result.failures`. Always check `result.copies.length`
against your requested count.

For large files, prefer streaming to minimize memory usage.

For uploading multiple files, use the split operations API directly:
createContexts() -> store() -> presignForCommit() -> pull() -> commit()

#### Parameters

| Parameter | Type | Description |
| ------ | ------ | ------ |
| `data` | [`UploadPieceStreamingData`](/reference/filoz/synapse-core/sp/type-aliases/uploadpiecestreamingdata/) | Raw bytes (Uint8Array) or ReadableStream to upload |
| `options?` | [`StorageManagerUploadOptions`](/reference/filoz/synapse-sdk/storage/interfaces/storagemanageruploadoptions/) | Upload options including contexts, callbacks, and abort signal |

#### Returns

[`Promise`](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)\<[`UploadResult`](/reference/filoz/synapse-sdk/synapse/interfaces/uploadresult/)\>

Upload result with pieceCid, size, copies array, and failures array

#### Throws

StoreError if primary store fails (before any data is committed)

#### Throws

CommitError if all commit attempts fail (data stored but not on-chain)