R2 Prompt Loader
ComfyUI custom node for Cloudflare R2 (S3-compatible) object storage - read/write text, browse/upload images with thumbnail gallery
R2 Prompt Loader — ComfyUI Custom Node
ComfyUI custom node for reading/writing text files and browsing/uploading images from/to Cloudflare R2 (S3-compatible) object storage, with a built-in thumbnail gallery.
Features
- Text operations: Browse directories, read
.txtfiles, write/save text prompts to R2 - Image gallery: Thumbnail gallery with lazy loading, batch fetching (8 per batch), scroll-to-load
- Image operations: Browse, delete, and upload images from/to R2
- S3-compatible: Works with any S3-compatible object storage (Cloudflare R2, AWS S3, MinIO, etc.)
Installation
Clone into your ComfyUI/custom_nodes/ directory:
cd ComfyUI/custom_nodes/
git clone https://github.com/<YOUR_USERNAME>/r2-prompt-loader
pip install -r r2-prompt-loader/requirements.txt
Restart ComfyUI.
Usage
- Add R2 Prompt Loader node (category:
R2 Tools) - Enter your S3 endpoint, access key, secret key, and bucket name
- Click 登录 to test the connection
- Browse directories and files, or use the image gallery
Node Inputs
| Input | Type | Description |
|-------|------|-------------|
| endpoint | STRING | S3 endpoint URL |
| access_key | STRING | Access Key ID |
| secret_key | STRING | Secret Access Key |
| bucket | COMBO | Bucket name |
| directory | COMBO | Directory prefix (click ↻ to list) |
| file | COMBO | .txt file selection (click ↻ to list) |
| image_file | COMBO | Image file selection (click to preview) |
| text_to_save | STRING | Text content to write to R2 |
| save_filename | STRING | Save path (default: prompts/new_prompt.txt) |
| upload_image | IMAGE | Connect an image node output, click 存图 to upload |
Node Outputs
| Output | Type | Description |
|--------|------|-------------|
| text | STRING | File content or upload result message |
| image | IMAGE | Selected image tensor [1, H, W, 3] (float32 0-1) |
Buttons
- 登录 — Test R2 connection, auto-refresh lists on success
- 写入 — Save text to R2
- 删除 — Delete selected
.txtfile - ↻ Dir / ↻ Files — Refresh directory/file lists
- 删图 (red) — Delete selected image
- 存图 (blue) — Queue workflow to upload connected image to R2
File Structure
custom_nodes/r2-prompt-loader/
├── __init__.py # ComfyUI extension entry point
├── node.py # R2PromptLoader node definition
├── server.py # Backend API routes (9 endpoints)
├── requirements.txt # Python dependencies
└── js/
└── main.js # Frontend JS extension
API Routes
Mounted at /r2-prompt-loader/api/:
| Route | Method | Description |
|-------|--------|-------------|
| /test | POST | Test R2 connection |
| /list_dirs | POST | List subdirectories |
| /list_txt | POST | List .txt files |
| /list_images | POST | List image files |
| /get_image | POST | Get full-resolution image |
| /get_thumbnail | POST | Get 200px JPEG thumbnail (~10KB) |
| /write_txt | POST | Write text file |
| /delete_txt | POST | Delete text file |
| /delete_image | POST | Delete image file |
License
MIT