firebase-storage-kit

StorageManager

Main entry point for uploads and file operations.

StorageManager is the class you instantiate with a Firebase Storage instance. It starts uploads, exposes global state, and provides file query helpers.

Constructor

import { getStorage } from "firebase/storage";
import { StorageManager } from "firebase-storage-kit";

const manager = new StorageManager(getStorage(app));

Methods

uploadFile

uploadFile(file: File, options: UploadOptions): UploadHandle

Starts a single resumable upload. Returns an UploadHandle immediately — the upload runs asynchronously.

uploadFiles

uploadFiles(
  files: File[],
  optionsFor: (file: File, index: number) => UploadOptions,
  batchOptions?: BatchOptions
): BatchHandle

Uploads multiple files as one batch. See BatchHandle.

getState

getState(): StorageState

Returns { uploads, batches } — current snapshots of all tracked uploads and batches.

subscribe

subscribe(listener: (state: StorageState) => void): () => void

Calls listener on every state change. Returns an unsubscribe function.

exists

exists(path: string): Promise<boolean>

true if the object exists; false if not found; throws on other errors.

getMetadata

getMetadata(path: string): Promise<FileMetadata>

Returns object metadata. Throws if not found.

getDownloadURL

getDownloadURL(path: string): Promise<string>

Returns a download URL for the object at path.

downloadStream

downloadStream(
  path: string,
  options?: DownloadStreamOptions
): Promise<DownloadStreamResult>

Fetches the object and returns a ReadableStream<Uint8Array> without buffering the whole download in memory. onProgress(loaded, total) runs as the caller consumes chunks from the stream, and signal accepts an AbortSignal for cancellation.

const controller = new AbortController();
const { stream, totalBytes, contentType } = await manager.downloadStream(
  "videos/launch-demo.mp4",
  {
    signal: controller.signal,
    onProgress: (loaded, total) => {
      console.log(`${Math.round((loaded / total) * 100)}%`);
    },
  }
);

The returned totalBytes comes from file's object metadata. Progress does not advance until stream is read, piped, or otherwise consumed.

delete

delete(path: string): Promise<void>

Deletes the object at path.

list

list(prefix: string, options?: ListOptions): Promise<StorageListResult>

Lists folders and files at prefix with optional pagination (maxResults, pageToken).

listAll

listAll(prefix: string): Promise<StorageListResult>

Lists all folders and files at prefix (auto-paginates internally).

On this page