From 2da1a53062f9a72eb2af07c1d4cbf88e96eebe51 Mon Sep 17 00:00:00 2001 From: liuwei Date: Thu, 12 Jun 2025 12:03:49 +0800 Subject: [PATCH] =?UTF-8?q?=E5=8A=A0=E5=85=A5=E7=B1=BB=E5=9E=8B=E8=BD=AC?= =?UTF-8?q?=E6=8D=A2=E9=80=BB=E8=BE=91=EF=BC=8C=E9=98=B2=E6=AD=A2=E8=A7=A3?= =?UTF-8?q?=E7=A0=81=E5=A4=B1=E8=B4=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- admin/dashboard/blueprints/message_push.py | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/admin/dashboard/blueprints/message_push.py b/admin/dashboard/blueprints/message_push.py index fbc94f1..5862984 100644 --- a/admin/dashboard/blueprints/message_push.py +++ b/admin/dashboard/blueprints/message_push.py @@ -541,12 +541,10 @@ def upload_file(): file_type = 'video' if file and allowed_file(file.filename, file_type): - # 获取原始文件名和扩展名 - original_filename = secure_filename(file.filename) - file_ext = original_filename.rsplit('.', 1)[1].lower() - - # 生成唯一文件名,保持原始扩展名 - unique_filename = f"{uuid.uuid4().hex}.{file_ext}" + # 生成安全的文件名 + filename = secure_filename(file.filename) + # 生成唯一文件名 + unique_filename = f"{uuid.uuid4().hex}.{filename}" # 确保上传目录存在 upload_folder = os.path.join(current_app.root_path, 'static', 'uploads')