Nodes/comfyui_image2oss/从oss加载图片
ComfyUI Node

从oss加载图片

Pull images out of an Alibaba OSS bucket and straight into your graph

By nxt5656·Created about a year ago·Updated 8 days ago· 0
从oss加载图片
    • IMAGE
    filenametmp/screenshot.png
    access_key_idaccess_key_id
    access_key_secretaccess_key_secret
    security_token
    bucket_namebucket_name
    endpointoss-cn-hangzhou.aliyuncs.com

    Ever wished the input image for your workflow lived in an Alibaba Cloud OSS bucket instead of a folder on disk? That's the entire job of this node. It's the "read" half of the nxt5656/image2oss pack - no model, no GPU work, just a small HTTP client that reaches into your bucket, grabs one object, and drops it onto the canvas as a normal IMAGE tensor that everything downstream can consume.

    That sounds niche until you've built an automated pipeline: images generated on one machine, uploaded to shared storage, and a ComfyUI worker somewhere else that needs to pick them up and run img2img on them. Or you keep your reference library in a bucket and want to skip the download step entirely. Either way, this node replaces "manually move the file into input/" with a wire.

    How it works

    Under the hood it uses the oss2 Python SDK with StsAuth (Alibaba's signature v2 auth), opens the bucket, and calls get_object() with the key you give it. The bytes come back, get decoded by Pillow, converted to RGB, and normalized to the 0–1 float tensor shape ComfyUI expects. Note that uploads in this pack are always PNG, but loading works on whatever you stored.

    The inputs that matter

    Four of the six fields do the real work:

    • filename - the full object key in the bucket, including any folder prefix. tmp/screenshot.png means the object literally named tmp/screenshot.png, not a file called screenshot.png somewhere in a tmp folder.
    • access_key_id / access_key_secret - your long-lived Alibaba Cloud keys. This is the direct-auth version of the pack.
    • security_token - leave this empty unless your keys are STS-style temporary credentials.
    • bucket_name and endpoint - bucket + region. endpoint is a dropdown of 44 Alibaba regions, and the node's VALIDATE_INPUTS rejects anything that isn't one of them, so don't hand-type a custom endpoint.

    The one output is IMAGE, wired to whatever needs the picture - VAE encode, a ControlNet preprocessor, an img2img sampler, anything that takes an image tensor.

    Install

    ComfyUI Manager (search "image2oss"), or comfy node registry-install image2oss, or the old-school route:

    cd ComfyUI/custom_nodes
    git clone https://github.com/nxt5656/image2oss
    

    Then restart ComfyUI. The only dependency that isn't already in a stock ComfyUI is oss2, which the pack's requirements.txt installs (oss2, numpy, requests, pillow, torch). No model files, no heavy downloads - the pack does bundle a 16MB CJK font, but that's only used by the watermark nodes, not this one.

    Where people get burned

    • The key in the workflow file. Your AK/SK live in the node widgets, which means they're saved into the .json of any workflow you save. Email a workflow with real keys in it and you've handed over cloud credentials. This is the standard caution for any node that carries credentials (the KB's external-api-nodes doc hammers this exact point). Use the STS-service variants of this pack if the workflow might leave your machine.
    • Wrong object key - the classic failure. get_object on a key that doesn't exist raises NoSuchKey and the error you'll see names the object and bucket, which makes it easy to spot a missing tmp/ prefix or a typo'd folder.
    • Endpoint mismatch. Region dropdown says one thing, your bucket actually lives in another - fix the dropdown, don't type around it.
    CategoryAPI/oss

    Inputs (6)

    NameTypeDefaultDescription
    filenameSTRINGtmp/screenshot.png
    access_key_idSTRINGaccess_key_id
    access_key_secretSTRINGaccess_key_secret
    security_tokenSTRING
    bucket_nameSTRINGbucket_name
    endpointCOMBOoss-cn-hangzhou.aliyuncs.com44 options: oss-cn-hangzhou.aliyuncs.com, oss-cn-shanghai.aliyuncs.com, oss-cn-qingdao.aliyuncs.com, oss-cn-beijing.aliyuncs.com, oss-cn-shenzhen.aliyuncs.com, oss-cn-heyuan.aliyuncs.com, +38

    Outputs (1)

    NameTypeDescription
    IMAGEIMAGE