From 97df73f7293ddcb18f4aa166b9c69d9cbc50f73b Mon Sep 17 00:00:00 2001 From: aaron <> Date: Wed, 12 Feb 2025 22:25:18 +0800 Subject: [PATCH] update. --- app/core/qcloud.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/app/core/qcloud.py b/app/core/qcloud.py index c4c8e93..3099391 100644 --- a/app/core/qcloud.py +++ b/app/core/qcloud.py @@ -171,8 +171,14 @@ class QCloudManager: # 生成存储路径 folder = folder or datetime.now().strftime('%Y%m%d') - ext = file.filename.split('.')[-1] if '.' in file.filename else '' - key = f"{folder}/{uuid.uuid4()}.{ext}" + + # 获取文件名 + if file.filename: + ext = file.filename.split('.')[-1] if '.' in file.filename else '' + name = file.filename.split('.')[0] if '.' in file.filename else file.filename + key = f"{folder}/{name}_{uuid.uuid4()}.{ext}" + else: + key = f"{folder}/{uuid.uuid4()}.{ext}" # 上传文件 self.cos_client.put_object(