AI & Agents

Firebase Storage File Size Limit: Client SDKs, Cloud Functions, and Bucket Quotas

The Firebase Storage file size limit reaches 5 TB per object at the Google Cloud Storage bucket layer, but real-world application architectures encounter much tighter boundaries. Firebase Cloud Functions enforce a strict 10MB or 32MB HTTP payload ceiling, while mobile and web SDKs require resumable chunking to avoid timeouts on files exceeding 100MB. Mastering these constraints determines whether file ingestion pipelines run smoothly or crash under load.

Tom Langridge 14 min read Updated
Comparing Google Cloud Storage object ceilings against Cloud Functions HTTP payload limits and mobile client constraints.

What Are the Documented Firebase Storage File Size Limits Across Tiers?

The Firebase Storage file size limit begins with Google Cloud Storage's maximum object size of 5 TiB (approximately 5 TB), but treating 5 TB as an actionable upload boundary is the quickest way to crash a production system. While the underlying Google Cloud Storage bucket infrastructure accepts multi-terabyte objects, real-world applications almost never interact with raw bucket endpoints in isolation. Between an end-user device and the storage disk sits an entire chain of client libraries, mobile network radios, HTTP proxies, security rule evaluators, and serverless compute runtimes.

The Firebase Storage file size limit is backed by Google Cloud Storage's 5 TB per object ceiling, but practical uploads via client SDKs and Cloud Functions are constrained by 10MB to 32MB payload limits.

When developers evaluate upload boundaries for Cloud Storage for Firebase, they must account for constraints at each layer of the technical stack:

Storage Tier / Layer Documented Ceiling Primary Bottleneck / Failure Mode Recommended Upload Method
Cloud Storage Bucket Object 5 TiB (5 TB) Bucket quota exhaustion / billing runaway Resumable or multipart composition
Firebase Cloud Functions (1st gen) 10MB HTTP payload HTTP 413 Payload Too Large / function crash Direct bucket upload via Signed URL
Cloud Run Functions (2nd gen) 32MB HTTP payload HTTP 413 Payload Too Large / memory exhaustion Direct bucket upload via Signed URL
Eventarc Storage Triggers 512 KB event payload Event size limit exceeded Passing metadata reference, not file bytes
Client SDK (Monolithic) Practical timeout on large files Memory pressure, cellular dropouts Direct in-memory transfer for small files
Client SDK (Resumable) Bucket quota (up to 5 TB) App suspension on mobile devices uploadBytesResumable() with chunk tracking

Google Cloud Storage stores data as immutable binary objects. According to the official Google Cloud Storage quotas, this limit applies regardless of write method, including object composition, resumable uploads, and multipart uploading. You can write an individual object up to 5 TiB into a bucket, but doing so requires composable multipart uploads or resumable session URLs. Writing directly to a bucket without chunking or session tracking leaves the transfer vulnerable to any dropped TCP packet.

Most web and mobile applications do not upload directly via raw Google Cloud Storage REST APIs. Instead, they rely on the Firebase Client SDKs or route files through backend middleware. That architectural choice introduces the real-world boundaries where most systems break.

How Client SDKs Handle Large Uploads: Resumable Sessions vs Direct Bytes

The Firebase Client SDKs for Web, iOS, Android, and Flutter provide two distinct methods for writing files to storage: monolithic byte transfers and resumable upload tasks. Selecting the wrong method for files larger than a few megabytes is the primary source of failed client uploads.

Monolithic transfers using uploadBytes() or uploadString() read the entire file payload into client memory and dispatch a single HTTP PUT request to Google Cloud Storage. If the network drops for even a fraction of a second near the end of a multi-megabyte video upload, the entire request fails. The client must retransmit the complete payload from byte zero.

On mobile devices, monolithic transfers create severe memory pressure. Buffering high-resolution video or uncompressed audio files into application memory can trigger an Out-Of-Memory (OOM) termination by the mobile operating system, crashing the app before the HTTP request even leaves the device.

The Resumable Upload Protocol

To handle large files reliably, the Firebase Client SDK provides uploadBytesResumable(). This method initiates a resumable upload session with the underlying Google Cloud Storage endpoint:

  1. The client sends an initial metadata request to create a unique resumable upload session URI.
  2. The SDK splits the source file into structured byte chunks.
  3. The client uploads each chunk sequentially over HTTP.
  4. If a connection interruption occurs, the SDK queries the storage endpoint for the byte offset of the last acknowledged chunk.
  5. The upload resumes from the acknowledged byte offset rather than restarting from the beginning.
import { getStorage, ref, uploadBytesResumable, getDownloadURL } from 'firebase/storage';

function uploadLargeFile(file: File, path: string): Promise<string> {
  const storage = getStorage();
  const storageRef = ref(storage, path);
  const uploadTask = uploadBytesResumable(storageRef, file);
  return new Promise((resolve, reject) => {
    uploadTask.on(
      'state_changed',
      (snapshot) => {
        const progress = (snapshot.bytesTransferred / snapshot.totalBytes) * 100;
        console.log(`Upload progress: ${progress.toFixed(2)}%`);
      },
      (error) => {
        console.error('Upload failed with status:', error.code);
        reject(error);
      },
      async () => {
        const downloadURL = await getDownloadURL(uploadTask.snapshot.ref);
        resolve(downloadURL);
      }
    );
  });
}

Operational Reliability Tiers for Client SDK Transfers

Operational stability varies depending on the payload size and the transfer method used:

File Size Range Recommended Client Method Expected Network and Platform Behavior
Under 10MB Monolithic uploadBytes() Efficient for user profile photos, icons, and small thumbnail images.
10MB to 100MB Resumable uploadBytesResumable() Protects against Wi-Fi drops, packet loss, and cellular network handoffs.
100MB to 500MB Resumable with pause and resume Requires application-level session controls to handle transient device sleeps.
Over 500MB Background transfer / Cloud Import Mobile OS background suspension policies require native background workers.

For applications handling very large video or dataset assets, desktop browsers can complete resumable uploads, but mobile operating systems often terminate long-running transfers when users switch apps. In these scenarios, native background uploaders or server-side transfer connectors are necessary.

Why Cloud Functions Fail on Uploads: The 10MB and 32MB Payload Bottleneck

The most frequent breaking point in Firebase upload pipelines occurs when teams route file uploads through Firebase Cloud Functions. Developers often attempt this pattern to run authentication checks, scan attachments for viruses, or perform image transformations before persisting the file to storage.

When a client sends a file payload inside an HTTP POST request to a Firebase Cloud Function, the request hits a hard Google Cloud platform limit.

First-generation Firebase Cloud Functions enforce a strict 10MB limit on uncompressed HTTP request bodies. Second-generation Cloud Functions (powered by Cloud Run) raise this limit to 32MB. Any HTTP request exceeding these ceilings fails immediately with an HTTP 413 Payload Too Large error before your function code even executes. As documented in the official Cloud Run functions quotas, incoming requests that exceed platform ceilings are rejected at the edge.

The Base64 Encoding Expansion

Developers frequently attempt to circumvent multipart form complexity by encoding binary files into Base64 strings inside a JSON request body. Base64 encoding introduces an overhead of roughly one-third, converting raw binary data into a substantially larger text representation.

Cloud Function Generation HTTP Request Ceiling Maximum Raw Binary Size via Base64
1st Generation Cloud Functions 10MB uncompressed Approximately 7.5MB raw binary
2nd Generation Cloud Run Functions 32MB uncompressed Approximately 24MB raw binary
Eventarc Storage Event Triggers 512 KB event payload Metadata reference only (no file content)

Furthermore, event-driven functions triggered by storage events (such as onObjectFinalized) receive CloudEvent metadata payloads that are capped at 512 KB under Eventarc. Attempting to pass document content or large custom metadata dictionaries through storage trigger events causes Eventarc to drop the invocation entirely.

The Decoupled Direct-to-Bucket Pattern

To process files larger than the 32MB HTTP payload limit in a serverless Firebase Cloud Functions architecture, you must decouple file transport from compute execution. The client must never send raw file bytes through the Cloud Function HTTP endpoint.

The production-grade pattern operates as follows:

Client App ---> 1. Direct Upload (Resumable) ---> Firebase Storage Bucket
                                                         |
                                               2. onObjectFinalized
                                                         v
Processed Data / DB <--- 4. Stream & Parse <--- Cloud Function
  1. Direct Upload: The client uploads the file directly to Firebase Storage using uploadBytesResumable() or a signed upload URL generated by the Firebase Admin SDK. Firebase Security Rules validate user permissions and file size ceilings at the bucket boundary.
  2. Event Notification: Once the object finishes uploading, Google Cloud Storage triggers an asynchronous background Cloud Function (storage.onObjectFinalized).
  3. Metadata Payload: The Cloud Function receives only the lightweight metadata object (bucket name, file path, generation ID, content type), keeping the event payload well below the 512 KB Eventarc limit.
  4. Streamed Processing: If the Cloud Function needs to read the file (for example, to extract metadata or generate document embeddings), it streams the object directly from the bucket using the Cloud Storage Node.js client or a temporary disk file in /tmp.

Because the function streams the file from storage rather than ingesting it over an inbound HTTP request, it is bounded only by the instance memory allocation (which can scale up to 32 GB on 2nd gen functions) rather than the 32MB HTTP payload cap.

Fastio features

Scale your document storage beyond serverless payload limits

Give your team and AI agents intelligent workspaces with built-in indexing, remote MCP connectivity, and persistent file versioning. Every organization starts with a 14-day free trial.

How to Enforce File Size Limits and Quotas with Firebase Security Rules

Because Google Cloud Storage buckets support objects up to 5 TB by default, deploying a Firebase Storage bucket without explicit security rules creates severe financial and operational exposure. A single malicious user or a misconfigured test script could upload hundreds of gigabytes of data, exhausting your project quota and producing unexpected storage and bandwidth charges.

Firebase Storage Security Rules provide declarative access control evaluated directly at the bucket edge before bytes land on disk. To restrict upload sizes, rules inspect the request.resource.size attribute, which measures the incoming object size in bytes.

It is critical to distinguish between request.resource.size and resource.size:

  • request.resource.size: Evaluates the size of the pending file being uploaded or updated.
  • resource.size: Evaluates the size of the existing file already stored in the bucket.

Production Security Rule Examples

The following rules demonstrate how to apply fine-grained file size ceilings based on path, file type, and user attributes:

rules_version = '2';
service firebase.storage {
  match /b/{bucket}/o {
    // User avatar uploads: max 5MB, images only
    match /users/{userId}/avatar/{imageId} {
      allow read: if true;
      allow write: if request.auth != null 
                   && request.auth.uid == userId
                   && request.resource.size < 5 * 1024 * 1024
                   && request.resource.contentType.matches('image/(jpeg|png|webp)');
    }
    // Business document uploads: max 25MB, PDF only
    match /organizations/{orgId}/documents/{docId} {
      allow read: if request.auth != null;
      allow write: if request.auth != null
                   && request.resource.size < 25 * 1024 * 1024
                   && request.resource.contentType == 'application/pdf';
    }
    // Premium tier uploads: conditional size based on custom claims
    match /workspace/{workspaceId}/media/{fileId} {
      allow read: if request.auth != null;
      allow write: if request.auth != null
                   && (
                     (request.auth.token.tier == 'premium' && request.resource.size < 200 * 1024 * 1024)
                     || (request.resource.size < 20 * 1024 * 1024)
                   );
    }
  }
}

Pre-Validation on the Client

Security rules protect infrastructure at the server boundary, but relying on security rules alone produces poor user experience. If a user on a mobile connection uploads a file exceeding the permitted ceiling, the rule evaluation terminates the transfer with a storage/unauthorized error, wasting time and device bandwidth.

Production client applications must validate file dimensions and byte counts locally before dispatching the upload request:

function validateAndUpload(file: File, maxBytes: number) {
  if (file.size > maxBytes) {
    const maxMb = (maxBytes / (1024 * 1024)).toFixed(0);
    throw new Error(`File size (${(file.size / (1024 * 1024)).toFixed(1)} MB) exceeds the ${maxMb} MB limit.`);
  }
  const allowedTypes = ['application/pdf', 'image/png', 'image/jpeg'];
  if (!allowedTypes.includes(file.type)) {
    throw new Error(`Unsupported file type: ${file.type}`);
  }
  // Proceed with resumable upload
}

Client validation delivers immediate user feedback, while Firebase Security Rules enforce immutable boundaries that cannot be bypassed by modified HTTP requests or third-party API clients.

Architectural Patterns for Ingesting Large Files into AI Retrieval Workspaces

The rapid adoption of generative AI agents and retrieval-augmented generation (RAG) pipelines has introduced a new class of storage challenges. Autonomous agents frequently process document archives, comprehensive legal discovery packages, technical manuals, and multimedia files that overwhelm traditional serverless upload pipelines.

When integrating AI models with cloud storage, engineering teams hit two compounding ceilings:

  1. Serverless Transport Limits: Firebase Cloud Functions terminate HTTP uploads at 10MB or 32MB, requiring custom signed URL infrastructure or multi-step cloud staging.
  2. Model Context Windows: While contemporary models offer expanded context windows, stuffing raw multi-megabyte files directly into LLM prompts produces high latency, token bloat, and context degradation. Model context windows and chat interfaces enforce strict file upload caps and token boundaries that degrade when fed monolithic documents.

To support autonomous agents that need to inspect, query, and extract data from large corporate corpora, teams are adopting decoupled intelligent workspaces designed for agent interaction.

The Decoupled Intelligent Workspace Pattern

Instead of writing custom OCR workers, vector database sync jobs, and chunking scripts in Cloud Functions, teams place files into intelligent workspaces built specifically for agent workflows.

In this architecture, document management and AI retrieval are decoupled from ephemeral serverless compute:

  • Centralized Document Ingestion: Files are uploaded directly to shared workspaces, either through web interfaces or automated cloud import from services like Google Drive, Dropbox, Box, and OneDrive.
  • Automated Intelligence Indexing: When workspace intelligence is enabled, the platform indexes documents on arrival. Files become immediately searchable through hybrid keyword, semantic, and metadata queries without maintaining standalone vector infrastructure.
  • Remote Tool Calling via MCP: AI assistants (including Claude, Codex, Cursor, and OpenClaw) connect through storage for agents using the remote Fast.io MCP endpoints over Streamable HTTP: https://mcp.fast.io/mcp/tools for Claude and OpenClaw, https://mcp.fast.io/mcp/code for Cursor, and https://mcp.fast.io/mcp/operations for Codex.
  • Citation-Backed Retrieval: Instead of feeding an entire technical manual into an LLM context window, the agent queries the workspace search endpoint. The workspace returns relevant passages with exact source citations, keeping prompt size minimal and responses verifiable.
  • Structured Data Extraction: Teams use Metadata Views to convert unstructured contracts, financial receipts, and technical forms into typed, queryable databases without complex parsing code.

For multi-agent teams configuring persistent storage, workspaces preserve full per-file version history, record an append-only audit trail, and support durable, branded shares with recipient-level access controls.

Plan Ceilings and Resource Allocation

Organizations scaling their storage infrastructure can review plan allocations on the Fast.io pricing page:

Plan Tier Monthly Billing Annual Billing Storage & Workspaces Monthly Credits Maximum Upload File Size
Starter $9.99/mo $99/yr 250 GB storage, 5 workspaces, 3 seats 100,000 25 GB per file
Business $49.99/mo $499/yr 5 TB storage, 50 workspaces, 10 seats 600,000 50 GB per file
Enterprise $199.99/mo $1,999/yr 25 TB storage, 200 workspaces, 30 seats 3,000,000 100 GB per file

Monthly plans start with a 14-day free trial that requires a credit card. These generous per-file upload ceilings give developers and AI agents the headroom needed to ingest large datasets without running into serverless HTTP bottlenecks.

Sources

References used to verify factual claims in this guide.

  1. Google Cloud Storage bucket objects and Firebase storage uploads enforce a maximum individual object file size limit of 5 TiB across all methods.

  2. Google Cloud Run functions and Firebase HTTP requests enforce uncompressed payload limits of 10MB on 1st gen and 32MB on 2nd gen functions.

Frequently Asked Questions

What is the maximum file size for Firebase Storage?

The maximum file size for an individual object in Firebase Storage is 5 TB (5 TiB), which matches the underlying Google Cloud Storage object quota. However, direct HTTP uploads to Firebase Cloud Functions are limited to 10MB on 1st gen and 32MB on 2nd gen functions. Browser and mobile client SDKs face network disconnects on unchunked files, making resumable uploads necessary for larger transfers.

Can I upload a 1GB file using the Firebase Storage client SDK?

Yes, you can upload a 1GB file using the Firebase Storage client SDK by calling uploadBytesResumable() rather than uploadBytes(). The resumable upload protocol breaks the file into structured byte chunks and tracks session progress, allowing the transfer to recover from network disconnects without restarting from byte zero. On mobile devices, ensure the application maintains background execution permissions during the transfer.

Why does my Firebase Cloud Function return an HTTP 413 error during file uploads?

An HTTP 413 Payload Too Large error occurs when an incoming HTTP request body exceeds the platform limits enforced by Google Cloud Functions. First-generation functions enforce a 10MB uncompressed request ceiling, while second-generation functions enforce a 32MB ceiling. If your client Base64-encodes binary data into JSON, the one-third encoding overhead triggers this error on even smaller files. To resolve this, upload files directly to Firebase Storage using the client SDK or signed URLs, and trigger the Cloud Function via an asynchronous storage event.

How do I restrict file upload sizes using Firebase Storage Security Rules?

You restrict upload sizes in Firebase Storage Security Rules by evaluating the request.resource.size attribute within an allow write rule. The size value is specified in bytes. For example, evaluating request.resource.size against a byte threshold enforces the exact limit specified in your rule equation. Always evaluate request.resource.size for incoming writes rather than resource.size, which references the existing object already stored in the bucket.

How should AI agents and RAG pipelines handle documents that exceed Cloud Functions payload limits?

AI agents and RAG pipelines should avoid passing raw document bytes through serverless HTTP functions. Instead, place documents into an intelligent workspace that indexes content on arrival. Autonomous agents then connect via the Model Context Protocol (MCP) to query relevant document passages using semantic and keyword search. This pattern avoids serverless payload ceilings, prevents context window bloat, and returns precise citations for generated answers.

Related Resources

Fastio features

Scale your document storage beyond serverless payload limits

Give your team and AI agents intelligent workspaces with built-in indexing, remote MCP connectivity, and persistent file versioning. Every organization starts with a 14-day free trial.