From 9e32de99227ac9e2eaef53ef7d4efe8144ec2ce0 Mon Sep 17 00:00:00 2001 From: Ching L Date: Thu, 6 Mar 2025 09:26:45 +0800 Subject: [PATCH] fix: Update image upload method with explicit file name parameter --- image_generator.py | 4 ++-- utils.py | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/image_generator.py b/image_generator.py index 624f934..ffef3ff 100644 --- a/image_generator.py +++ b/image_generator.py @@ -133,7 +133,7 @@ class ImageGenerator: await browser.close() # 上传图片 - image_url = utils.upload_image(image_path) + image_url = utils.upload_image(image_path, image_path) # 删除本地文件 try: @@ -216,7 +216,7 @@ class ImageGenerator: await browser.close() # 上传图片 - image_url = utils.upload_image(image_path) + image_url = utils.upload_image(image_path, image_path) # 删除本地文件 try: diff --git a/utils.py b/utils.py index b367b19..ff46385 100644 --- a/utils.py +++ b/utils.py @@ -271,7 +271,7 @@ def upload_image(image_path, file_name=None): # 生成唯一的文件名 if not file_name: - timestamp = datetime.now().strftime('%Y%m%d%H%M%S') + timestamp = datetime.datetime.now().strftime('%Y%m%d%H%M%S') random_id = str(uuid.uuid4())[:8] file_extension = os.path.splitext(image_path)[1] object_key = f'dotabot/{timestamp}_{random_id}{file_extension}'