GEMINI LABJP
FLASH — Gemini 3.5 Flash is now generally available and powers gemini-flash-latestAGENTS — Managed Agents in the Gemini API enter public preview, running autonomously in Google-hosted isolated Linux sandboxesSTUDIO — Google AI Studio adds project-level spend caps and native Android vibe codingLIVE — Gemini 3.1 Flash Live Preview, an audio-to-audio model for real-time dialogue, is now availableIMAGE — Nano Banana 2 Lite arrives as the fastest, most cost-efficient image model, and Gemini Omni Flash is in API previewLYRIA — Lyria 3 music generation models (clip-preview and pro-preview) are now availableFLASH — Gemini 3.5 Flash is now generally available and powers gemini-flash-latestAGENTS — Managed Agents in the Gemini API enter public preview, running autonomously in Google-hosted isolated Linux sandboxesSTUDIO — Google AI Studio adds project-level spend caps and native Android vibe codingLIVE — Gemini 3.1 Flash Live Preview, an audio-to-audio model for real-time dialogue, is now availableIMAGE — Nano Banana 2 Lite arrives as the fastest, most cost-efficient image model, and Gemini Omni Flash is in API previewLYRIA — Lyria 3 music generation models (clip-preview and pro-preview) are now available
Articles/Workspace
Workspace/2026-07-10Advanced

Resuming Large Gemini Files API Uploads Across the Apps Script 6-Minute Limit

Sending a few hundred megabytes from Drive to the Gemini Files API through Apps Script means fighting a 6-minute execution cap and payload limits. Here is how to decompose resumable upload into start, upload, query and finalize so a killed run never loses progress.

gemini98apps-script9files-api5google-workspace7resumable-upload

Premium Article

A 380 MB promo video sitting in Drive killed my Apps Script run with "Exceeded maximum execution time." All I wanted was a monthly pass where Gemini watched the footage for one of the apps I maintain as an indie developer. Handing a blob straight to UrlFetchApp does not survive the first step.

The Files API and the Apps Script execution model were never designed for each other. One assumes you can hand over a large file in a single motion. The other guarantees your function dies at six minutes, no negotiation. Bridging them means rebuilding the transfer as a state machine that expects to be interrupted.

Pin down the hard numbers first

Before writing anything, it helps to know exactly which walls are load-bearing. These are the limits Google documents.

ItemValueWhat it forces
When Files API is requiredTotal request over 100 MBBelow that, inline data is fine
Inline limit for PDFs50 MBPDFs cross the line sooner
Maximum size per file2 GBAnything larger must be split first
Storage per project20 GBAbandoned files quietly eat the quota
Retention48 hoursAuto-deleted, and never downloadable

The API itself costs nothing and is available in every region where Gemini is. The number that shapes the design is 48 hours. It is a constraint, but it also happens to be the foundation for idempotency, which I will come back to.

Resumable upload is three commands, not one

Underneath the SDK, Files API uploads speak Google's standard resumable protocol. Drop to REST and the three phases become visible.

Phase one is start. No file bytes travel. You send metadata and receive an upload URL.

curl "https://generativelanguage.googleapis.com/upload/v1beta/files" \
  -H "x-goog-api-key: ${GEMINI_API_KEY}" \
  -D headers.tmp \
  -H "X-Goog-Upload-Protocol: resumable" \
  -H "X-Goog-Upload-Command: start" \
  -H "X-Goog-Upload-Header-Content-Length: 398458880" \
  -H "X-Goog-Upload-Header-Content-Type: video/mp4" \
  -H "Content-Type: application/json" \
  -d '{"file": {"display_name": "promo-2026-07"}}'
 
# The destination comes back in a response header
grep -i "x-goog-upload-url" headers.tmp

Phase two is upload. You push bytes at the URL, declaring their position with X-Goog-Upload-Offset. Only the final chunk carries upload, finalize, which seals the file.

Phase three is query. It rarely shows up in sample code, yet it is the one command that makes recovery correct. It asks the server how many bytes it has actually accepted.

If nothing can interrupt you, none of this matters. For anything under 100 MB I still reach for a single client.files.upload() call. Decomposition only earns its keep when the process running the transfer is expected to die.

Thank you for reading this far.

Continue Reading

What follows includes implementation code, benchmarks, and practical content we hope you'll find useful. This site runs without ads — server and development costs are supported entirely by members like you. If it's been helpful, we'd be truly grateful for your support.

WHAT YOU'LL LEARN
You can replace an upload that keeps dying at the 6-minute mark with a transfer that picks up exactly where it stopped
You will be able to use the resumable query command to read the server's true offset, eliminating duplicate chunks and offset drift
You can turn the 48-hour Files API retention window into an idempotency key, skipping re-uploads of unchanged Drive files entirely
Secure payment via Stripe · Cancel anytime

Unlock This Article

Get full access to the rest of this article. Buy once, read anytime. This site is ad-free — your support goes directly toward keeping it running.

or
Unlock all articles with Membership →
Share

Thank You for Reading

Gemini Lab is ad-free, supported entirely by members like you. We publish practical guides daily with implementation code, benchmarks, and production-ready patterns. If you've found it useful, we'd love to have you on board.

  • Copy-paste ready implementation code
  • New advanced guides published daily
  • $5/mo or $10 for lifetime access
View Membership →

Related Articles

Workspace2026-06-29
When Apps Script Time-Driven Triggers Quietly Run Out: Consolidating Gemini Automations into One Dispatcher
Apps Script caps you at 20 triggers per user and a daily total trigger-runtime budget. Here is how to stop your Gemini automations from silently dying as you add more, using a single dispatcher, a schedule table, and an external heartbeat.
Workspace2026-04-09
Google Forms × Gemini API: Automated Response Analysis — Sentiment Analysis, Theme Extraction & Report Generation
Learn how to connect Google Forms with the Gemini API to automatically perform sentiment analysis, theme extraction, and report generation on survey responses. Includes complete Apps Script and Python implementation code you can deploy today.
Workspace2026-03-29
Gemini × Google Workspace Add-ons Development Guide — From Building Custom AI Side Panels to Marketplace Launch
A comprehensive guide to building custom AI side panels with Google Workspace Add-ons and Gemini API — from implementation to Marketplace publication and monetization.
📚RECOMMENDED BOOKS
Build a Large Language Model (From Scratch)
Sebastian Raschka
LLM Dev
Prompt Engineering for LLMs
Berryman & Ziegler
Prompting
AI Engineering
Chip Huyen
AI Eng
* Contains affiliate links
See all →