firebase-storage-kit

Types

Shared TypeScript types exported by firebase-storage-kit.

Key types re-exported from firebase-storage-kit. Import them alongside classes:

import type {
  UploadOptions,
  UploadItem,
  StorageState,
} from "firebase-storage-kit";

UploadOptions

Options for a single upload (uploadFile or per-file in uploadFiles):

interface UploadOptions {
  path: string;
  validate?: UploadValidationOptions;
  retry?: RetryOptions | false;
  contentType?: string;
  customMetadata?: Record<string, string>;
}

UploadValidationOptions

Pre-upload validation rules. See Validation for usage and error handling.

interface UploadValidationOptions {
  maxSizeBytes?: number;
  allowedMimeTypes?: string[];
  allowedExtensions?: string[];
  maxImageWidth?: number;
  maxImageHeight?: number;
}

RetryOptions

interface RetryOptions {
  maxRetries?: number;
  initialDelayMs?: number;
  maxDelayMs?: number;
  jitter?: boolean;
  isRetryable?: (error: Error) => boolean;
}

UploadItem

Live state for one file:

interface UploadItem {
  id: string;
  file: File;
  path: string;
  progress: number;
  bytesTransferred: number;
  totalBytes: number;
  status: UploadStatus;
  downloadURL?: string;
  error?: Error;
  attempt?: number;
  /** @deprecated alias of `attempt` */
  retryAttempt?: number;
  batchId?: string;
}

UploadStatus

type UploadStatus =
  | "queued"
  | "uploading"
  | "retrying"
  | "paused"
  | "success"
  | "error"
  | "canceled";

StorageState

interface StorageState {
  uploads: UploadItem[];
  batches: UploadBatch[];
}

UploadBatch

interface UploadBatch {
  id: string;
  uploads: UploadItem[];
  totalProgress: number;
  completedCount: number;
  failedCount: number;
}

FileMetadata

interface FileMetadata {
  name: string;
  bucket: string;
  size: number;
  contentType?: string;
  timeCreated?: string;
  updated?: string;
  customMetadata?: Record<string, string>;
}

StorageListItem

interface StorageListItem {
  path: string;
  name: string;
}

StorageListResult

interface StorageListResult {
  prefixes: string[];
  items: StorageListItem[];
  nextPageToken?: string;
}

ListOptions

interface ListOptions {
  maxResults?: number;
  pageToken?: string;
}

Advanced exports

These are exported for testing and advanced use:

  • DEFAULT_RETRY_OPTIONS
  • resolveRetryOptions
  • computeRetryDelay
  • getStorageErrorCode
  • isRetryableStorageError
  • VALIDATION_ERROR_CODES
  • ValidationError
  • validateUpload, validateUploadSync, validateImageDimensions, validateImageDimensionLimits
  • getFileExtension, readImageDimensions

On this page