From 730bf56ed4c3712cdad7f4680f91f9e75ecce253 Mon Sep 17 00:00:00 2001 From: piexlmax <303176530@qq.com> Date: Thu, 31 Mar 2022 22:14:54 +0800 Subject: [PATCH] =?UTF-8?q?=E6=97=A5=E5=BF=97=E4=B8=AD=E9=97=B4=E4=BB=B6?= =?UTF-8?q?=E5=AF=B9=E4=BA=8E=E4=B8=8A=E4=BC=A0=E6=96=87=E4=BB=B6=E5=81=9A?= =?UTF-8?q?body=E8=BF=87=E6=BB=A4=E5=A4=84=E7=90=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- server/middleware/operation.go | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/server/middleware/operation.go b/server/middleware/operation.go index dba9a2a7..a2067480 100644 --- a/server/middleware/operation.go +++ b/server/middleware/operation.go @@ -64,11 +64,12 @@ func OperationRecord() gin.HandlerFunc { Body: string(body), UserID: userId, } - // 存在某些未知错误 TODO - //values := c.Request.Header.Values("content-type") - //if len(values) >0 && strings.Contains(values[0], "boundary") { - // record.Body = "file" - //} + // 上传文件时候 中间件日志进行裁断操作 + if strings.Index(c.GetHeader("Content-Type"), "multipart/form-data") > -1 { + if len(record.Body) > 512 { + record.Body = "File or Length out of limit" + } + } writer := responseBodyWriter{ ResponseWriter: c.Writer, body: &bytes.Buffer{}, -- GitLab