◉GEMINI LABJP
●ARGON — gemini-4-argon is generally available as of 10/13, aimed at complex coding, agents, math and science●DEEP RES — deep-research-pro-preview-12-2025 shuts down 10/23, 6 days left. Move to deep-research-preview-04-2026●NANO — gemini-nano-banana-2.1 is GA (10/06). gemini-3.1-flash-image is deprecated with no shutdown date yet●MCP — One write-up cut an 85,000-token tool result to 310 tokens by wrapping it in an ADK FunctionTool●FLASH — gemini-3.7-flash and 3.5-flash now route automatically to newer Flash models (10/08)●NEW — Stop Re-Reading Every Crash Report: Gre…●ARGON — gemini-4-argon is generally available as of 10/13, aimed at complex coding, agents, math and science●DEEP RES — deep-research-pro-preview-12-2025 shuts down 10/23, 6 days left. Move to deep-research-preview-04-2026●NANO — gemini-nano-banana-2.1 is GA (10/06). gemini-3.1-flash-image is deprecated with no shutdown date yet●MCP — One write-up cut an 85,000-token tool result to 310 tokens by wrapping it in an ADK FunctionTool●FLASH — gemini-3.7-flash and 3.5-flash now route automatically to newer Flash models (10/08)●NEW — Stop Re-Reading Every Crash Report: Gre…
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.

gemini119apps-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-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.
◧ Workspace2026-10-15
Before you turn on Meet's automatic notes: three things to settle in the calendar event
Some Meet note-taking settings can't be changed once someone has joined the call. Here is what to decide in the calendar event first — language, sharing scope, how it starts — and how to tell participants, following Google's help pages.