StorageContext
Defined in: packages/synapse-sdk/src/storage/context.ts:60
Constructors
Section titled “Constructors”Constructor
Section titled “Constructor”new StorageContext( synapse, warmStorageService, provider, dataSetId, options, dataSetMetadata): StorageContext;
Defined in: packages/synapse-sdk/src/storage/context.ts:134
Parameters
Section titled “Parameters”Parameter | Type |
---|---|
synapse | Synapse |
warmStorageService | WarmStorageService |
provider | ProviderInfo |
dataSetId | number |
options | StorageServiceOptions |
dataSetMetadata | Record <string , string > |
Returns
Section titled “Returns”StorageContext
Properties
Section titled “Properties”dataSetId
Section titled “dataSetId”readonly dataSetId: number;
Defined in: packages/synapse-sdk/src/storage/context.ts:84
serviceProvider
Section titled “serviceProvider”readonly serviceProvider: string;
Defined in: packages/synapse-sdk/src/storage/context.ts:85
Accessors
Section titled “Accessors”dataSetMetadata
Section titled “dataSetMetadata”Get Signature
Section titled “Get Signature”get dataSetMetadata(): Record<string, string>;
Defined in: packages/synapse-sdk/src/storage/context.ts:98
Returns
Section titled “Returns”Record
<string
, string
>
provider
Section titled “provider”Get Signature
Section titled “Get Signature”get provider(): ProviderInfo;
Defined in: packages/synapse-sdk/src/storage/context.ts:93
Returns
Section titled “Returns”withCDN
Section titled “withCDN”Get Signature
Section titled “Get Signature”get withCDN(): boolean;
Defined in: packages/synapse-sdk/src/storage/context.ts:88
Returns
Section titled “Returns”boolean
Methods
Section titled “Methods”download()
Section titled “download()”download(pieceCid, options?): Promise<Uint8Array<ArrayBufferLike>>;
Defined in: packages/synapse-sdk/src/storage/context.ts:1227
Download data from this specific service provider
Parameters
Section titled “Parameters”Parameter | Type | Description |
---|---|---|
pieceCid | string | PieceLink | The PieceCID identifier |
options? | DownloadOptions | Download options |
Returns
Section titled “Returns”Promise
<Uint8Array
<ArrayBufferLike
>>
The downloaded data
getDataSetPieces()
Section titled “getDataSetPieces()”getDataSetPieces(): Promise<PieceLink[]>;
Defined in: packages/synapse-sdk/src/storage/context.ts:1258
Get the list of piece CIDs for this service service’s data set by querying the PDP server.
Returns
Section titled “Returns”Array of piece CIDs as PieceCID objects
getProviderInfo()
Section titled “getProviderInfo()”getProviderInfo(): Promise<ProviderInfo>;
Defined in: packages/synapse-sdk/src/storage/context.ts:1250
Get information about the service provider used by this service
Returns
Section titled “Returns”Provider information including pricing (currently same for all providers)
hasPiece()
Section titled “hasPiece()”hasPiece(pieceCid): Promise<boolean>;
Defined in: packages/synapse-sdk/src/storage/context.ts:1268
Check if a piece exists on this service provider.
Parameters
Section titled “Parameters”Parameter | Type | Description |
---|---|---|
pieceCid | string | PieceLink | The PieceCID (piece CID) to check |
Returns
Section titled “Returns”Promise
<boolean
>
True if the piece exists on this provider, false otherwise
pieceStatus()
Section titled “pieceStatus()”pieceStatus(pieceCid): Promise<PieceStatus>;
Defined in: packages/synapse-sdk/src/storage/context.ts:1294
Check if a piece exists on this service provider and get its proof status. Also returns timing information about when the piece was last proven and when the next proof is due.
Note: Proofs are submitted for entire data sets, not individual pieces. The timing information returned reflects when the data set (containing this piece) was last proven and when the next proof is due.
Parameters
Section titled “Parameters”Parameter | Type | Description |
---|---|---|
pieceCid | string | PieceLink | The PieceCID (piece CID) to check |
Returns
Section titled “Returns”Status information including existence, data set timing, and retrieval URL
preflightUpload()
Section titled “preflightUpload()”preflightUpload(size): Promise<PreflightInfo>;
Defined in: packages/synapse-sdk/src/storage/context.ts:898
Run preflight checks for an upload
Parameters
Section titled “Parameters”Parameter | Type | Description |
---|---|---|
size | number | The size of data to upload in bytes |
Returns
Section titled “Returns”Preflight information including costs and allowances
providerDownload()
Section titled “providerDownload()”providerDownload(pieceCid, options?): Promise<Uint8Array<ArrayBufferLike>>;
Defined in: packages/synapse-sdk/src/storage/context.ts:1241
Download data from the service provider
Parameters
Section titled “Parameters”Parameter | Type |
---|---|
pieceCid | string | PieceLink |
options? | DownloadOptions |
Returns
Section titled “Returns”Promise
<Uint8Array
<ArrayBufferLike
>>
terminate()
Section titled “terminate()”terminate(): Promise<TransactionResponse>;
Defined in: packages/synapse-sdk/src/storage/context.ts:1421
Terminates the data set by sending on-chain message. This will also result in the removal of all pieces in the data set.
Returns
Section titled “Returns”Transaction response
upload()
Section titled “upload()”upload(data, options?): Promise<UploadResult>;
Defined in: packages/synapse-sdk/src/storage/context.ts:918
Upload data to the service provider
Parameters
Section titled “Parameters”Parameter | Type |
---|---|
data | | ArrayBuffer | Uint8Array <ArrayBufferLike > |
options? | UploadOptions |
Returns
Section titled “Returns”create()
Section titled “create()”static create( synapse, warmStorageService,options): Promise<StorageContext>;
Defined in: packages/synapse-sdk/src/storage/context.ts:172
Static factory method to create a StorageContext Handles provider selection and data set selection/creation
Parameters
Section titled “Parameters”Parameter | Type |
---|---|
synapse | Synapse |
warmStorageService | WarmStorageService |
options | StorageServiceOptions |
Returns
Section titled “Returns”Promise
<StorageContext
>
performPreflightCheck()
Section titled “performPreflightCheck()”static performPreflightCheck( warmStorageService, paymentsService, size,withCDN): Promise<PreflightInfo>;
Defined in: packages/synapse-sdk/src/storage/context.ts:865
Static method to perform preflight checks for an upload
Parameters
Section titled “Parameters”Parameter | Type | Description |
---|---|---|
warmStorageService | WarmStorageService | WarmStorageService instance |
paymentsService | PaymentsService | PaymentsService instance |
size | number | The size of data to upload in bytes |
withCDN | boolean | Whether CDN is enabled |
Returns
Section titled “Returns”Preflight check results without provider/dataSet specifics