阿里云OSS文件上传
From ComfyUI tensor to a signed OSS URL in one node
- image
- oss_urls
- public_urls
- upload_info
Sooner or later you'll have a ComfyUI image that a remote API needs to fetch - an image-translate service, a template renderer, an edit model that only accepts URLs. That's exactly the gap this node fills: it takes an IMAGE tensor (or local files) and uploads it to Alibaba Cloud OSS, then hands you back a URL the outside world can hit. For the API-heavy pack it lives in, it's the piece that closes the loop between "local pixels" and "cloud service".
The mechanism is plain oss2 - Alibaba's official Python SDK. You give it an endpoint, a domain, a bucket_name, and credentials; it turns your tensor into PNG bytes (JPEG or WEBP if your object key ends .jpg/.webp) and PUTs them to OSS. An object_key template with {timestamp}, {index}, and {name} placeholders keeps names unique and organized - default uploads/image_{timestamp}_{index}. use_timestamp appends a Unix timestamp to avoid collisions. batch_upload (default on) walks every image in a batch and uploads each as its own object.
The inputs you'll actually set
bucket_name- required, your OSS bucket. Empty → error.access_key_id/access_key_secret- Alibaba Cloud AccessKey. The node also reads the env varsOSS_ACCESS_KEY,OSS_ACCESS_SECRET,OSS_BUCKET, andOSS_DOMAIN, so you can keep keys out of the workflow file.image- optional IMAGE input. Give it a tensor, get it uploaded.file_paths- optional, one local path per line, uploaded as-is with their extension.object_key- the key template (see above).make_public- sets apublic-readACL if you want anyone to fetch it without a signature.content_type- defaultimage/png; for file uploads it's inferred from the extension instead.
Outputs
oss_urls- JSON array of object keys.public_urls- JSON array of signed GET URLs (valid for an hour). These are what you hand to a downstream API node or a browser.upload_info- JSON summary: success counts, ETag, request ID, per-file results. Your debugging friend.
The one dependency that bites
The pack does not install oss2 for you. The source catches a missing import and just prints a warning in red and returns an error JSON. The moment you hit "oss2 库未安装", that's the fix:
pip install oss2
then restart ComfyUI. After that, the usual suspects: wrong region/endpoint mismatch, an AccessKey without bucket write permission, and a bucket name that doesn't exist. Oh, and public_urls are signed even when make_public is off - that's fine, just don't paste them into a workflow you're sharing after the hour expires.
Installing the pack
cd ComfyUI/custom_nodes
git clone https://github.com/jinchanz/ComfyUI-ADIC
Restart, or grab it via ComfyUI Manager under "ComfyUI-ADIC". No model downloads. You'll need a real Alibaba Cloud account with a bucket before this node does anything useful - it's pure cloud plumbing.
Inputs (13)
| Name | Type | Default | Description |
|---|---|---|---|
| endpoint | STRING | https://oss-cn-hangzhou.aliyuncs.com | — |
| region | STRING | cn-hangzhou | — |
| domain | STRING | oss-cn-hangzhou.aliyuncs.com | — |
| bucket_name | STRING | — | |
| object_key | STRING | uploads/image_{timestamp}_{index} | — |
| imageopt | IMAGE | — | |
| file_pathsopt | STRING | — | |
| access_key_idopt | STRING | — | |
| access_key_secretopt | STRING | — | |
| content_typeopt | STRING | image/png | — |
| use_timestampopt | BOOLEAN | true | — |
| make_publicopt | BOOLEAN | false | — |
| batch_uploadopt | BOOLEAN | true | — |
Outputs (3)
| Name | Type | Description |
|---|---|---|
| oss_urls | STRING | — |
| public_urls | STRING | — |
| upload_info | STRING | — |