diff --git a/server/upload/internal/logic/uploadlogologic.go b/server/upload/internal/logic/uploadlogologic.go index bd495c61..0318e245 100644 --- a/server/upload/internal/logic/uploadlogologic.go +++ b/server/upload/internal/logic/uploadlogologic.go @@ -95,6 +95,12 @@ func (l *UploadLogoLogic) UploadLogo(req *types.UploadLogoReq, userinfo *auth.Us return resp.SetStatus(basic.CodeFileUploadErr, "file upload err,file is not image") } + // 限制上传文件大小 50k + maxSize := 100 * 1024 + if fileHeader.Size > int64(maxSize) { + return resp.SetStatus(basic.CodeFileUploadErr, "file upload err,The file size exceeds the maximum limit of 100k") + } + // 读取数据流 ioData, err := io.ReadAll(fileObject) if err != nil {