From dd2f8a1352d53c9d3bb2577144ff09a8a21d3261 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 37f0e0f559..ceec69a3df 100644 --- a/services/context/api.go +++ b/services/context/api.go @@ -290,7 +290,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 91484c5ba3..8ecfcd04c3 100644 --- a/services/context/context.go +++ b/services/context/context.go @@ -181,7 +181,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 }