Nodes/ComfyUI-ADIC/阿里云OSS文件上传
ComfyUI Node

阿里云OSS文件上传

From ComfyUI tensor to a signed OSS URL in one node

By jinchanz·Created about a year ago·Updated a day ago· 5
阿里云OSS文件上传
  • image
  • oss_urls
  • public_urls
  • upload_info
endpointhttps://oss-cn-hangzhou.aliyuncs.com
regioncn-hangzhou
domainoss-cn-hangzhou.aliyuncs.com
bucket_name
object_keyuploads/image_{timestamp}_{index}
file_paths
access_key_id
access_key_secret
content_typeimage/png
use_timestamptrue
make_publicfalse
batch_uploadtrue

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 vars OSS_ACCESS_KEY, OSS_ACCESS_SECRET, OSS_BUCKET, and OSS_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 a public-read ACL if you want anyone to fetch it without a signature.
  • content_type - default image/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.

CategoryMalette

Inputs (13)

NameTypeDefaultDescription
endpointSTRINGhttps://oss-cn-hangzhou.aliyuncs.com
regionSTRINGcn-hangzhou
domainSTRINGoss-cn-hangzhou.aliyuncs.com
bucket_nameSTRING
object_keySTRINGuploads/image_{timestamp}_{index}
imageoptIMAGE
file_pathsoptSTRING
access_key_idoptSTRING
access_key_secretoptSTRING
content_typeoptSTRINGimage/png
use_timestampoptBOOLEANtrue
make_publicoptBOOLEANfalse
batch_uploadoptBOOLEANtrue

Outputs (3)

NameTypeDescription
oss_urlsSTRING
public_urlsSTRING
upload_infoSTRING