Nodes/ComfyUI Gemini Pro Node/gemini-pro-文件上传
ComfyUI Node

gemini-pro-文件上传

Drive

By penposs·Created about a year ago·Updated 9 months ago· 12
gemini-pro-文件上传
    • file
    file_path./sample.mp3

    Gemini File Upload is the least glamorous node in the penposs Gemini pack, and arguably the most honest one. It does one job: take a file path, upload that file to Google's Files API, and hand you back a GEMINI_FILE handle for the next node to chew on. No prompts, no temperature, no opinions. Just a pipe.

    Why it exists

    The Gemini API can't take arbitrary huge files inline - there's a size limit on what you can stuff directly into a generation request. Files that won't fit get uploaded once, get an ID, and then you reference that ID. That's exactly what this node is for: big audio, long documents, videos, anything you'd feed to Gemini File Processing afterward.

    It does the work by copying your file to a temp directory, calling genai.upload_file() on it, deleting the temp copy, and returning the uploaded handle. Under the hood it also registers a custom ComfyUI type - GEMINI_FILE - so the output plugs cleanly into the matching input on the File Processing node.

    The gotcha that will bite you

    Here's where the pack's hobbyist roots show. The source hardcodes its temp directory as I:\ComfyUI_windows_portable\ComfyUI\temp - literally the author's own Windows machine, baked into the code. What happens on your machine:

    • On a standard Windows install with no I: drive, creating that directory fails and the node returns a "无法创建临时目录" (can't create temp directory) error.
    • On Linux or macOS it doesn't crash - os.makedirs cheerfully creates a relative I:/ComfyUI_windows_portable/... folder wherever ComfyUI happens to be running. Files land in a weird nested dir. It works, it's just ugly.

    Either way, the upload succeeds and the temp file gets deleted afterward, so it's a papercut rather than a blocker - but if you see errors about temp directories, this is why. You can't fix it from the UI; you'd have to patch the source.

    The other thing to know: no api_key here

    Notice this node has no api_key input. It reads the key only from the pack's config.json. So the workflow order matters: run the main Gemini Pro node once with your key (it saves config.json), or drop a config.json into the pack folder by hand. Otherwise File Upload returns "未在配置文件中找到有效的 API Key" and goes nowhere.

    Install and wiring

    It's the same pack as the main node, so install once and you get all three:

    cd ComfyUI/custom_nodes
    git clone https://github.com/penposs/ComfyUI_Gemini_Pro.git
    

    (Or search "ComfyUI Gemini Pro" in ComfyUI Manager.) Restart ComfyUI afterward.

    The only real input is file_path - a plain string, default ./sample.mp3, pointing at whatever you want to upload. Output is a single GEMINI_FILE named file, which you feed straight into the file input of Gemini File Processing. That's the entire flow: File Upload makes the file reference, File Processing asks the questions.

    It's not a node you'll spend much time with - you set a path and forget it. Just remember the key must live in config.json first, and that your file is heading to Google's servers, not staying local. Keep that in mind before you upload anything you'd rather not.

    CategoryGemini Pro

    Inputs (1)

    NameTypeDefaultDescription
    file_pathSTRING./sample.mp3

    Outputs (1)

    NameTypeDescription
    fileGEMINI_FILE