Nodes/ComfyUI-NanoBanana2/NanoBanana - Files Upload
ComfyUI Node

NanoBanana - Files Upload

Upload a big file once, reuse the handle instead of re-sending it

By IxMxAMAR·Created 6 months ago·Updated about a month ago· 4
NanoBanana - Files Upload
  • network
  • file_uri
  • file_name
api_key
file_path
display_name
mime_type

Gemini accepts PDFs, video, audio, and images as context - but pasting a 200-page PDF or a big video into a prompt body is a mess and a waste of tokens. Google has a Files API for exactly this: you upload the file once, get back a reusable URI, and reference that URI in any number of calls. This node is the upload half of that flow, and it's the piece the pack was missing before v2.1.

Where you'd use it: the classic PDF-QA workflow (upload a document, then ask questions against it with the pack's file-based vision/chat nodes), or captioning a video without re-encoding it into every prompt. Upload once, reuse everywhere, and when the file expires you re-upload. It's the "stop re-encoding your big inputs" node.

How it works

You give it an absolute file_path and it calls client.files.upload(), returning a handle. Two optional fields smooth the edges: display_name for a human-readable label, and mime_type to override auto-detection when the extension is ambiguous. The response gives you two outputs:

  • file_uri - the reusable files/... URI that goes into downstream nodes' file inputs.
  • file_name - the name Google assigned on the server.

One important caveat baked into the API: uploaded files live for roughly 48 hours server-side, then expire. That's a Google policy, not a pack quirk - plan your workflows around it (upload, process, done), and don't build a pipeline that expects a file uploaded last week to still be there.

Installation

Part of the NanoBanana2 pack:

cd ComfyUI/custom_nodes
git clone https://github.com/IxMxAMAR/ComfyUI-NanoBanana2
pip install google-genai

ComfyUI Manager: search NanoBanana2. Needs a Gemini API key from aistudio.google.com.

Gotchas

The obvious one: the file path is a local absolute path on the machine running ComfyUI, so it works on your box but breaks the moment you share the workflow - you'll see "File not found: ..." with your local path in the error. Also, size limits are real - the pack's docs mention PDFs up to ~1000 pages and video/audio up to ~1 GiB for the paired "ask uploaded file" node, so don't point it at a 5 GB render and expect a miracle. And because the 48-hour expiry is silent until a URI 404s, a workflow that was fine last week can mysteriously fail today - re-running the upload node fixes it, which is the standard rhythm.

CategoryNanoBanana2/Files

Inputs (5)

NameTypeDefaultDescription
api_keySTRING
file_pathSTRINGAbsolute path to the file (PDF, video, audio, image).
display_nameoptSTRINGOptional human-readable name for the upload.
mime_typeoptSTRINGOverride the MIME type if auto-detection fails.
networkoptNB_NETWORKOptional. Wire a NanoBanana - Network Route node here to route this request through that proxy (e.g. US egress).

Outputs (2)

NameTypeDescription
file_uriSTRING
file_nameSTRING