StorageManager
Defined in: packages/synapse-sdk/src/storage/manager.ts:124
Constructors
Section titled “Constructors”Constructor
Section titled “Constructor”new StorageManager(
options):StorageManager
Defined in: packages/synapse-sdk/src/storage/manager.ts:135
Creates a new StorageManager
Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
options | StorageManagerOptions | The options for the StorageManager StorageManagerOptions |
Returns
Section titled “Returns”StorageManager
Methods
Section titled “Methods”createContext()
Section titled “createContext()”createContext(
options?):Promise<StorageContext>
Defined in: packages/synapse-sdk/src/storage/manager.ts:679
Create a single storage context with specified options
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
options? | StorageServiceOptions |
Returns
Section titled “Returns”createContexts()
Section titled “createContexts()”createContexts(
options?):Promise<StorageContext[]>
Defined in: packages/synapse-sdk/src/storage/manager.ts:621
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:
- Specified datasets (
dataSetIds) - uses their existing providers - Specified providers (
providerIds) - finds or creates matching datasets - 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
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
options? | CreateContextsOptions | Configuration options CreateContextsOptions |
Returns
Section titled “Returns”Promise resolving to array of storage contexts
download()
Section titled “download()”download(
options):Promise<Uint8Array<ArrayBufferLike>>
Defined in: packages/synapse-sdk/src/storage/manager.ts:504
Download data from storage If context is provided, routes to context.download() Otherwise performs SP-agnostic download
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
options | StorageManagerDownloadOptions |
Returns
Section titled “Returns”Promise<Uint8Array<ArrayBufferLike>>
findDataSets()
Section titled “findDataSets()”findDataSets(
options?):Promise<EnhancedDataSetInfo[]>
Defined in: packages/synapse-sdk/src/storage/manager.ts:752
Query data sets for this client
Parameters
Section titled “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
Section titled “Returns”Promise<EnhancedDataSetInfo[]>
Array of enhanced data set information including management status
getDefaultContext()
Section titled “getDefaultContext()”getDefaultContext():
Promise<StorageContext>
Defined in: packages/synapse-sdk/src/storage/manager.ts:742
Get or create the default context
Returns
Section titled “Returns”getStorageInfo()
Section titled “getStorageInfo()”getStorageInfo():
Promise<StorageInfo>
Defined in: packages/synapse-sdk/src/storage/manager.ts:773
Get comprehensive information about the storage service including approved providers, pricing, contract addresses, and current allowances
Returns
Section titled “Returns”Complete storage service information
preflightUpload()
Section titled “preflightUpload()”preflightUpload(
options):Promise<PreflightInfo>
Defined in: packages/synapse-sdk/src/storage/manager.ts:572
Run preflight checks for an upload without creating a context
Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
options | { metadata?: Record<string, string>; size: number; withCDN?: boolean; } | The options for the preflight upload |
options.metadata? | Record<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
Section titled “Returns”Preflight information including costs and allowances
terminateDataSet()
Section titled “terminateDataSet()”terminateDataSet(
options):Promise<`0x${string}`>
Defined in: packages/synapse-sdk/src/storage/manager.ts:764
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
Section titled “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
Section titled “Returns”Promise<`0x${string}`>
Transaction hash
upload()
Section titled “upload()”upload(
data,options?):Promise<UploadResult>
Defined in: packages/synapse-sdk/src/storage/manager.ts:165
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
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
data | UploadPieceStreamingData | Raw bytes (Uint8Array) or ReadableStream to upload |
options? | StorageManagerUploadOptions | Upload options including contexts, callbacks, and abort signal |
Returns
Section titled “Returns”Upload result with pieceCid, size, copies array, and failures array
Throws
Section titled “Throws”StoreError if primary store fails (before any data is committed)
Throws
Section titled “Throws”CommitError if all commit attempts fail (data stored but not on-chain)