From df370dd0beb3f380ee43c992412a1e60895382eb Mon Sep 17 00:00:00 2001 From: Mathieu Fenniak Date: Fri, 26 Dec 2025 20:26:37 -0700 Subject: [PATCH] fix: reduce memory usage while processing large attachment uploads --- services/context/api.go | 2 +- services/context/context.go | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/services/context/api.go b/services/context/api.go index 19e0c04911..9c478eacbb 100644 --- a/services/context/api.go +++ b/services/context/api.go @@ -291,7 +291,7 @@ func APIContexter() func(http.Handler) http.Handler { // If request sends files, parse them here otherwise the Query() can't be parsed and the CsrfToken will be invalid. if ctx.Req.Method == "POST" && strings.Contains(ctx.Req.Header.Get("Content-Type"), "multipart/form-data") { - if err := ctx.Req.ParseMultipartForm(setting.Attachment.MaxSize << 20); err != nil && !strings.Contains(err.Error(), "EOF") { // 32MB max size + if err := ctx.Req.ParseMultipartForm(32 << 20); err != nil && !strings.Contains(err.Error(), "EOF") { // 32MB max size ctx.InternalServerError(err) return } diff --git a/services/context/context.go b/services/context/context.go index 68074964c8..7c46fb7735 100644 --- a/services/context/context.go +++ b/services/context/context.go @@ -192,7 +192,7 @@ func Contexter() func(next http.Handler) http.Handler { // If request sends files, parse them here otherwise the Query() can't be parsed and the CsrfToken will be invalid. if ctx.Req.Method == "POST" && strings.Contains(ctx.Req.Header.Get("Content-Type"), "multipart/form-data") { - if err := ctx.Req.ParseMultipartForm(setting.Attachment.MaxSize << 20); err != nil && !strings.Contains(err.Error(), "EOF") { // 32MB max size + if err := ctx.Req.ParseMultipartForm(32 << 20); err != nil && !strings.Contains(err.Error(), "EOF") { // 32MB max size ctx.ServerError("ParseMultipartForm", err) return }