◉GEMINI LABJP
●2.5 ROUTE — From today, 12/1, calls to gemini-2.5-pro and 2.5-flash are rerouted to newer models automatically●CLI 0.71.1 — Gemini CLI stable is still v0.71.1, with a 0.73 nightly published on 11/30●INTRO END — Introductory pricing for 3.8, 3.7 and 3.6 Flash ends on 12/31. 30 days left●VERTEX — Developers are asking how to run Gemini CLI with Vertex AI credentials●NEON — Gemini 4 Neon became generally available on 11/18 (paid tier only)●IMAGE TEXT — A new test shows text inside an image can sway Gemini's answer●2.5 ROUTE — From today, 12/1, calls to gemini-2.5-pro and 2.5-flash are rerouted to newer models automatically●CLI 0.71.1 — Gemini CLI stable is still v0.71.1, with a 0.73 nightly published on 11/30●INTRO END — Introductory pricing for 3.8, 3.7 and 3.6 Flash ends on 12/31. 30 days left●VERTEX — Developers are asking how to run Gemini CLI with Vertex AI credentials●NEON — Gemini 4 Neon became generally available on 11/18 (paid tier only)●IMAGE TEXT — A new test shows text inside an image can sway Gemini's answer
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.

gemini121apps-script10files-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-10-18
When the Gemini app can't reach Gmail or Drive: five places to check, starting with what you can fix yourself
When the Gemini app won't connect to Gmail, Drive or Calendar, or connects and still comes back empty, check your prompt, account, activity setting, smart features and admin settings, in that order.
◧ Workspace2026-07-16
I Put =GEMINI() in 420 Cells. The Calls Kept Coming on Days I Never Opened the Sheet
A custom function calling Gemini from Sheets looks best the moment it starts working, and it does not grow from there. Here is what the 30-second ceiling, uncontrolled recalculation, and read-only cells actually cost, measured, plus the code to move to a write-back design.
◧ Workspace2026-05-27
Replying to 11 Languages of Google Play Reviews With Gemini Without Sounding Like a Bot
After two major Android updates, I had to clear a backlog of unanswered Google Play reviews in Japanese, English, Traditional Chinese, Korean, Thai, Italian, Russian, Persian, Ukrainian, and Polish. This is the operations design I settled on for using Gemini as a translation and vocabulary partner without losing the human temperature.