This page is auto-generated from TypeDoc. Do not edit directly. To update, modify the TypeScript source in @lumeweb/pinner and run
pnpm generate:sdk.
Handles file uploads via XHR or TUS protocol based on file size.
Constructor
new UploadManager(config: PinnerConfig)| Parameter | Type | Description |
|---|---|---|
config | PinnerConfig | SDK configuration |
Methods
| Method | Returns | Description |
|---|---|---|
fetchUploadLimit() | Promise<number> | Fetch the upload size limit from the API. Falls back to 100 MB on failure. |
getUploadLimit() | number | Get the cached upload size limit (in bytes). Call fetchUploadLimit() first. |
upload(input, options) | Promise<UploadOperation> | Upload a file or stream to IPFS. |
uploadCar(input, options) | Promise<UploadOperation> | Upload a CAR file or stream directly without preprocessing. |
waitForOperation(input, options) | Promise<UploadResult> | Wait for an operation to complete or reach a settled state. Handles two scenarios: 1. If an operationId is provided (in UploadResult), uses it directly 2. If only CID is available, lists operations filtered by CID and polls the first result |
uploadDirectory(files, options) | Promise<UploadOperation> | Upload an array of files as an IPFS directory. |
destroy() | void |
fetchUploadLimit()
fetchUploadLimit(): Promise<number>Fetch the upload size limit from the API. Falls back to 100 MB on failure.
Returns: Promise<number>
getUploadLimit()
getUploadLimit(): numberGet the cached upload size limit (in bytes). Call fetchUploadLimit() first.
Returns: number
upload(input, options?)
upload(input: UploadInput, options?: UploadOptions): Promise<UploadOperation>Upload a file or stream to IPFS.
Parameters:
| Name | Type | Description |
|---|---|---|
input | UploadInput | File, stream, or upload object |
options | UploadOptions | Upload configuration optional |
Returns: Promise<UploadOperation>
uploadCar(input, options?)
uploadCar(input: File | ReadableStream<Uint8Array<ArrayBufferLike>>, options?: UploadOptions): Promise<UploadOperation>Upload a CAR file or stream directly without preprocessing.
Parameters:
| Name | Type | Description |
|---|---|---|
input | File | ReadableStream<Uint8Array<ArrayBufferLike>> | CAR file or stream |
options | UploadOptions | Upload configuration optional |
Returns: Promise<UploadOperation>
waitForOperation(input, options?)
waitForOperation(input: number | UploadResult, options?: any): Promise<UploadResult>Wait for an operation to complete or reach a settled state.
Handles two scenarios:
-
If an operationId is provided (in UploadResult), uses it directly
-
If only CID is available, lists operations filtered by CID and polls the first result
Parameters:
| Name | Type | Description |
|---|---|---|
input | number | UploadResult | Either an operation ID (number) or an UploadResult |
options | any | Polling options (interval, timeout, settledStates) optional |
Returns: Promise<UploadResult>
uploadDirectory(files, options?)
uploadDirectory(files: File[], options?: UploadOptions): Promise<UploadOperation>Upload an array of files as an IPFS directory.
Parameters:
| Name | Type | Description |
|---|---|---|
files | File[] | Files to upload |
options | UploadOptions | Upload configuration optional |
Returns: Promise<UploadOperation>
destroy()
destroy(): voidReturns: void
Source: upload/manager.ts