Merge pull request #73 from HAxiaoyu/fix/prevent-file-upload-logging

排除日志中的文件对象
This commit is contained in:
mizhexiaoxiao 2025-06-17 11:17:29 +08:00 committed by GitHub
commit 2c1873e823
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -68,7 +68,14 @@ class HttpAuditLogMiddleware(BaseHTTPMiddleware):
except json.JSONDecodeError:
try:
body = await request.form()
args.update(body)
# args.update(body)
for k, v in body.items():
if hasattr(v, "filename"): # 文件上传行为
args[k] = v.filename
elif isinstance(v, list) and v and hasattr(v[0], "filename"):
args[k] = [file.filename for file in v]
else:
args[k] = v
except Exception:
pass