Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Urgent: After Update, Upload File to S3 Doesn't upload multiple files properly. #21

Open
ckao10301 opened this issue Dec 14, 2024 · 1 comment

Comments

@ckao10301
Copy link

@TemryL Image Save node outputs 3 files. But the Upload File to S3 node uploads all of them with the same name, causing them to be overwritten. This never happened before the update when the s3_filename input was added.

Screenshot from 2024-12-13 17-15-32
Screenshot from 2024-12-13 17-15-58
upload s3 test workflow.json

@ckao10301
Copy link
Author

had chatgpt modify the code in upload_file_s3.py and it seems to have solved the problem. I didn't test it extensively but do you think you could pull in the changes from this?

import os
from ..client_s3 import get_s3_instance
S3_INSTANCE = get_s3_instance()

class UploadFileS3:
@classmethod
def INPUT_TYPES(s):
return {
"required":{
"s3_filename": ("STRING", {"default": ""}),
"local_path": ("STRING", {"default": "input/example.png"}),
"s3_folder": ("STRING", {"default": "output"}),
"delete_local": (["false", "true"],),
}
}

CATEGORY = "ComfyS3"
INPUT_NODE = True
OUTPUT_NODE = True
RETURN_TYPES = ("STRING",)
RETURN_NAMES = ("s3_paths",)
FUNCTION = "upload_file_s3"

def upload_file_s3(self, local_path, s3_folder, delete_local, s3_filename):
    if isinstance(local_path, str):
        local_path = [local_path]
    s3_paths = []
    for path in local_path:
        f_name = s3_filename if s3_filename else os.path.basename(path)
        s3_path = os.path.join(s3_folder, f_name)
        file_path = S3_INSTANCE.upload_file(path, s3_path)
        s3_paths.append(file_path)
        if delete_local == "true":
            os.remove(path)
            print(f"Deleted file at {path}")
    print(f"Uploaded file to S3 at {s3_path}")
    return { "ui": { "s3_paths": s3_paths },  "result": (s3_paths,) }

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant