UploadHandle
Control and observe a single file upload.
An UploadHandle is returned from StorageManager.uploadFile. Use it to pause, resume, cancel, and listen for progress.
Properties
| Property | Type | Description |
|---|---|---|
upload | UploadItem | Live upload state (mutates in place) |
Methods
pause
pause(): voidPauses the underlying Firebase upload task.
resume
resume(): voidResumes a paused upload.
cancel
cancel(): voidPermanently cancels the upload.
on
on<K extends keyof UploadHandleEvents>(
event: K,
listener: (payload: UploadHandleEvents[K]) => void
): thisSubscribe to events. Returns this for chaining.
Events
| Event | Payload | Description |
|---|---|---|
progress | UploadItem | Progress updated |
success | UploadItem | Upload completed |
error | UploadItem | Upload failed |
canceled | UploadItem | Upload canceled |
statusChange | UploadItem | Status changed |
retry | UploadRetryEvent | Retry scheduled |
UploadRetryEvent
interface UploadRetryEvent {
upload: UploadItem;
error: Error;
attempt: number;
maxAttempts: number;
delayMs: number;
}Example
const handle = manager.uploadFile(file, { path: "uploads/photo.jpg" });
handle
.on("progress", (u) => updateBar(u.progress))
.on("success", (u) => saveUrl(u.downloadURL))
.on("error", (u) => showError(u.error));
handle.pause();
handle.resume();
handle.cancel();