firebase-storage-kit

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

PropertyTypeDescription
uploadUploadItemLive upload state (mutates in place)

Methods

pause

pause(): void

Pauses the underlying Firebase upload task.

resume

resume(): void

Resumes a paused upload.

cancel

cancel(): void

Permanently cancels the upload.

on

on<K extends keyof UploadHandleEvents>(
  event: K,
  listener: (payload: UploadHandleEvents[K]) => void
): this

Subscribe to events. Returns this for chaining.

Events

EventPayloadDescription
progressUploadItemProgress updated
successUploadItemUpload completed
errorUploadItemUpload failed
canceledUploadItemUpload canceled
statusChangeUploadItemStatus changed
retryUploadRetryEventRetry 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();

On this page