feat(upload): 上传组件删除前需二次确认,支持ZIP/RAR/7Z压缩包上传

This commit is contained in:
DXC
2026-05-12 15:34:26 +08:00
parent 1edd471208
commit 6b4ebfa24f
2 changed files with 42 additions and 12 deletions

View File

@ -25,10 +25,10 @@ BASE_DIR = get_project_root()
UPLOAD_FOLDER = os.path.join(BASE_DIR, 'uploads')
# 允许上传的文件后缀
ALLOWED_EXTENSIONS = {'png', 'jpg', 'jpeg', 'gif', 'bmp', 'webp', 'pdf', 'doc', 'docx', 'xls', 'xlsx'}
ALLOWED_EXTENSIONS = {'png', 'jpg', 'jpeg', 'gif', 'bmp', 'webp', 'pdf', 'doc', 'docx', 'xls', 'xlsx', 'zip', 'rar', '7z'}
# ★ 文件上传安全加固:限制最大文件大小 (10MB)
MAX_CONTENT_LENGTH = 10 * 1024 * 1024 # 10MB
# ★ 文件上传安全加固:限制最大文件大小 (50MB,支持压缩包)
MAX_CONTENT_LENGTH = 50 * 1024 * 1024 # 50MB
def allowed_file(filename):
@ -68,7 +68,7 @@ def upload_file():
if file_size > MAX_CONTENT_LENGTH:
return jsonify({
"code": 400,
"msg": f"文件大小超过限制 ({MAX_CONTENT_LENGTH // (1024*1024)}MB)"
"msg": f"文件大小超过限制(最大 50MB"
}), 400
if file and allowed_file(file.filename):