Nodes/comfyui_image2oss/从oss加载图片(使用服务获取ak信息)
ComfyUI Node

从oss加载图片(使用服务获取ak信息)

Load from OSS without ever typing your Alibaba secret key

By nxt5656·Created about a year ago·Updated 8 days ago· 0
从oss加载图片(使用服务获取ak信息)
    • IMAGE
    • MASK
    filenametmp-comfyui/filename.jpeg
    sts_service_urlhttps://demo.cn/sts_service
    bucket_namebucket_name
    endpointoss-cn-hangzhou.aliyuncs.com

    This node does the same job as LoadImageFromOss - pull a picture out of an Alibaba OSS bucket and into your graph - minus the part where you paste long-lived cloud keys into a widget you'll forget to scrub before sharing. Instead of access_key_id and access_key_secret fields, it has one URL: a service you host that hands out short-lived credentials.

    That swap is the whole point, and it's the right call for anything that might leave your machine. The workflow file carries no secret at all. Worst case, someone gets a copy of the JSON and all they can do is ask your STS endpoint for another short-lived token - which is your call to grant or deny.

    How it works

    When the node runs, it does a GET on sts_service_url and expects this exact JSON shape back:

    {
      "success": true,
      "data": {
        "accessKeyId": "...",
        "accessKeySecret": "...",
        "securityToken": "..."
      }
    }
    

    If success isn't true, or the shape is wrong, the node raises. It then uses those temporary credentials with the oss2 SDK to fetch the object, decodes it, and returns it as a tensor. The service URL is expected to be your own backend - a small API, a cron-refreshed token cache, whatever - that proxies Alibaba's STS to mint short-lived keys. The pack doesn't provide that server; it just defines the contract.

    The inputs

    • filename - the full object key in the bucket (folders included).
    • sts_service_url - your credentials endpoint. Must be reachable from whatever machine runs ComfyUI, not just your laptop.
    • bucket_name and endpoint - endpoint is the 44-choice region dropdown; VALIDATE_INPUTS rejects anything typed by hand.

    The outputs - and why this one's better

    Two outputs: IMAGE and MASK. The mask is built from the image's alpha channel, inverted the same way ComfyUI's core Load Image does it - so white marks the region you'd inpaint or restrict sampling to. That's the useful difference from the direct-AK sibling: you get a usable mask for free, plus multi-frame (GIF) handling, where extra frames are skipped if their dimensions differ.

    Wire IMAGE into the pipeline and MASK into something like Set Latent Noise Mask or an inpainting conditioning path.

    Install

    ComfyUI Manager (search "image2oss"), or comfy node registry-install image2oss, or:

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

    Restart after. The only non-standard dependency is oss2; nothing model-shaped to download.

    Where people get burned

    • The response contract. Your service returns {"code": 200, ...} or wraps things differently - the node only understands success + data.accessKeyId/accessKeySecret/securityToken. Match the README's example exactly.
    • NoSuchKey. Same as the direct version: a typo in filename or a wrong bucket region surfaces as a missing-key error naming the object.
    • The service isn't the problem. If ComfyUI runs inside Docker or on a remote box, localhost in sts_service_url points at that machine, not yours.
    CategoryAPI/oss

    Inputs (4)

    NameTypeDefaultDescription
    filenameSTRINGtmp-comfyui/filename.jpeg
    sts_service_urlSTRINGhttps://demo.cn/sts_service
    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 (2)

    NameTypeDescription
    IMAGEIMAGE
    MASKMASK