Nodes/R2 Prompt Loader/R2 Prompt Loader
ComfyUI Node

R2 Prompt Loader

Your Prompt Library, Parked in Cloud Storage

By lvqunx·Created 2 months ago·Updated 2 months ago· 0
R2 Prompt Loader
  • upload_image
  • Text
  • Image
endpointhttps://a8bd0ac71a875091b6a56e195d309516.r2.cloudflarestorage.com
access_key
secret_key
bucket
directory
file
image_file
text_to_save
save_filenameprompts/new_prompt.txt

Don't be fooled by the name: R2 Prompt Loader doesn't load prompts from a file on your disk. It reads and writes them to Cloudflare R2 - or any S3-compatible bucket - straight from your graph, and it throws in a thumbnail gallery and one-click uploads while it's at it.

If everything you do lives on one machine, you don't need this node. Where it earns its keep is the setup where your prompts and outputs shouldn't live on that machine at all: a local box generating while a headless cloud worker renders, two ComfyUI installs that should share the same prompt library, or a pipeline where the "prompt" for a job is a .txt file written by something else entirely. R2 storage is cheap enough to treat as a scratch drive, which is exactly how the author seems to use it.

How it works

The node is two halves bolted together. At execution time, node.py runs a boto3 S3 client (v4 signature, region_name="auto", clients cached per endpoint+key). That's the actual read/write engine: it fetches the selected file, pushes text, or uploads an image. The browsing experience - the directory/file dropdowns, the gallery, the buttons - is a frontend extension (js/main.js) talking to nine backend routes mounted at /r2-prompt-loader/api that list objects, fetch 200px JPEG thumbnails in batches of eight, and delete on demand.

The buttons are labeled in Chinese, so here's your cheat sheet: 登录 tests the connection and refreshes the lists, ↻ Dir / ↻ Files reload the dropdowns, 写入 saves text, 删图 / 删除 delete the selected image or text file, and 存图 uploads. One warning before you click 存图: it calls app.queuePrompt(1), meaning it re-queues your entire workflow to run the upload - so if your graph also renders, expect it to render again. Keep upload-only workflows lean.

The inputs that matter

You set four things and forget the rest. endpoint, access_key, secret_key, and bucket are the whole connection. Then you point directory (a prefix, defaults to prompts/), pick a file (.txt) or image_file from the refreshed dropdowns, and you're reading.

The remaining inputs are for writing: text_to_save plus save_filename (default prompts/new_prompt.txt), and upload_image, an IMAGE input you wire from any generator - the node saves it as images/saved_<timestamp>.png. Outputs: Text (STRING) carries the file content and status messages like "Saved image: …", so treat it as a status channel too; Image (IMAGE) is your picked image as a [1, H, W, 3] float tensor, ready to feed an upscaler or sampler.

Installing

Clone it and restart:

cd ComfyUI/custom_nodes
git clone https://github.com/lvqunx/r2-prompt-loader
pip install -r r2-prompt-loader/requirements.txt

Or search "r2-prompt-loader" in ComfyUI Manager. Dependencies are just boto3, Pillow, and numpy - no model downloads, no GPU load, nothing heavy. One catch: the node is written against ComfyUI's newer backend node API (from comfy_api.latest import io, a comfy_entrypoint() extension), so it needs a reasonably recent ComfyUI. If the node doesn't show up under the "R2 Tools" category, update.

Where people trip

  • The defaults are the author's personal bucket. The shipped endpoint and bucket (z-image-turbo) belong to the author, not you. Plug in your own R2 (or MinIO, or AWS S3) credentials and bucket, or you'll just hit access errors.
  • Your secret key ends up in your saved workflows. These are plain string inputs, and ComfyUI bakes widget values into the workflow metadata embedded in every PNG you save - so sharing a workflow file leaks your R2 secret key. Don't share workflows built around this node without scrubbing the credentials out.
  • 存图 reruns everything, as noted. And the Text output mixes file contents with error/status strings, so don't build downstream logic that assumes it's pure file data.
  • R2 access from China: if you're the audience this author clearly built for, remember Cloudflare R2's region_name="auto" is doing real work - don't override it to a legacy region.

It's a small, personal-feeling tool - and that's fine. For "my prompts live in a bucket, not a folder," it's the only node I know that does the whole job in one box.

CategoryR2 Tools

Inputs (10)

NameTypeDefaultDescription
endpointSTRINGhttps://a8bd0ac71a875091b6a56e195d309516.r2.cloudflarestorage.com
access_keySTRING
secret_keySTRING
bucketCOMBO1 options: z-image-turbo
directoryCOMBO1 options: prompts/
fileCOMBO0 options:
image_fileCOMBO0 options:
text_to_saveoptSTRING
save_filenameoptSTRINGprompts/new_prompt.txt
upload_imageoptIMAGE

Outputs (2)

NameTypeDescription
TextSTRING
ImageIMAGE