Nodes/comfyui_image2oss/保存图片到oss(使用服务获取ak信息)
ComfyUI Node

保存图片到oss(使用服务获取ak信息)

Send ComfyUI outputs to Alibaba OSS without hardcoding cloud keys

By nxt5656·Created about a year ago·Updated 8 days ago· 0
保存图片到oss(使用服务获取ak信息)
  • images
    filename_prefix["tmp-comfyui/filename.jpeg"]
    sts_service_urlhttps://demo.cn/sts_service
    bucket_namebucket_name
    endpointoss-cn-hangzhou.aliyuncs.com

    The "write" half of nxt5656/image2oss. Hang this node at the end of a workflow and every image in the batch gets pushed to your Alibaba OSS bucket - no downloading, no manual upload, no cloud keys sitting in widgets. It's an output node, so it has no outputs and always runs last, and it fetches its credentials from a service you host instead of hardcoding AK/SK into the graph.

    If you're building an automated pipeline - generate on a schedule, dump results to a bucket, let a downstream app or website pick them up - this is the node that closes the loop. It's also the natural partner to the pack's loaders: produce here, consume somewhere else via LoadImageFromOss.

    How it works

    When it runs, the node GETs your sts_service_url and expects {"success": true, "data": {"accessKeyId", "accessKeySecret", "securityToken"}}. Then, for each image in the batch, it converts the tensor to a PIL image, encodes it as PNG, and calls put_object on the bucket. Everything is uploaded under the hardcoded prefix devops/comfyui/output/ inside the bucket, and each file gets auto-numbered with _1, _2, and so on.

    The inputs

    • images - the batch IMAGE from your sampler/VAE decode. One object per frame.
    • filename_prefix - here's the trap. The default value looks like a Python list literal, ["tmp-comfyui/filename.jpeg"], and you'd be forgiven for thinking this node parses it like the pack's other uploaders do. It doesn't. The code uses it as a literal string prefix and appends _n.png to it. Leave the default in and you'll get an object literally named devops/comfyui/output/["tmp-comfyui/filename.jpeg"]_1.png. Set something clean instead:
    screenshots/final
    

    That yields devops/comfyui/output/screenshots/final_1.png, final_2.png, …

    • sts_service_url, bucket_name, endpoint - the usual trio; endpoint is the 44-region dropdown and validation rejects anything typed by hand.

    Because filenames are generated automatically, there's no count-matching to worry about - the batch size just determines how many _n files land in the bucket.

    Install

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

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

    Restart after. The only extra dependency is oss2; no model files to download.

    Where people get burned

    • The prefix trap above. It's the single most confusing thing in this pack, because the default value is a string that looks like a list. Ignore the default; type a real prefix.
    • The hardcoded devops/comfyui/output/ path. You can't configure where in the bucket things land with this node. If you need full control over object paths, the direct-AK OSSUploadNode (the one that takes a real filename list) is the better fit.
    • Everything is PNG. Your file says .jpeg but the bytes are PNG - harmless for most uses, annoying if a downstream system insists on the extension matching.
    • Credentials never touch the workflow. Which is the whole point of the STS design, and why this is the variant I'd reach for whenever a workflow might get shared.
    CategoryAPI/oss

    Inputs (5)

    NameTypeDefaultDescription
    imagesIMAGE
    filename_prefixSTRING["tmp-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 (0)

    No outputs