排除日志中加入文件对象

This commit is contained in:
root 2025-06-01 21:09:40 +08:00
parent d32a1df922
commit 03a352c18e

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