Merge pull request #73 from HAxiaoyu/fix/prevent-file-upload-logging
排除日志中的文件对象
This commit is contained in:
commit
2c1873e823
@ -68,7 +68,14 @@ class HttpAuditLogMiddleware(BaseHTTPMiddleware):
|
|||||||
except json.JSONDecodeError:
|
except json.JSONDecodeError:
|
||||||
try:
|
try:
|
||||||
body = await request.form()
|
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:
|
except Exception:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user