fix: Update image upload method with explicit file name parameter

This commit is contained in:
Ching L 2025-03-06 09:26:45 +08:00
parent 5a6b5db082
commit 9e32de9922
2 changed files with 3 additions and 3 deletions

View File

@ -133,7 +133,7 @@ class ImageGenerator:
await browser.close() await browser.close()
# 上传图片 # 上传图片
image_url = utils.upload_image(image_path) image_url = utils.upload_image(image_path, image_path)
# 删除本地文件 # 删除本地文件
try: try:
@ -216,7 +216,7 @@ class ImageGenerator:
await browser.close() await browser.close()
# 上传图片 # 上传图片
image_url = utils.upload_image(image_path) image_url = utils.upload_image(image_path, image_path)
# 删除本地文件 # 删除本地文件
try: try:

View File

@ -271,7 +271,7 @@ def upload_image(image_path, file_name=None):
# 生成唯一的文件名 # 生成唯一的文件名
if not file_name: 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] random_id = str(uuid.uuid4())[:8]
file_extension = os.path.splitext(image_path)[1] file_extension = os.path.splitext(image_path)[1]
object_key = f'dotabot/{timestamp}_{random_id}{file_extension}' object_key = f'dotabot/{timestamp}_{random_id}{file_extension}'