From 34b90c62ca565dc12ccd4072801e3e13b976405c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nils=20O=2E=20Sel=C3=A5sdal?= Date: Sat, 29 Aug 2026 00:50:43 +0200 Subject: [PATCH] Increase default max upload size to 5GB --- main.go | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/main.go b/main.go index 54cd2f7..98b7a57 100644 --- a/main.go +++ b/main.go @@ -27,7 +27,12 @@ const idLength = 8 const idCharset = "abcdefghijklmnopqrstuvwxyz0123456789" // defaultMaxUploadSize is used when MAX_UPLOAD_SIZE is not set. -const defaultMaxUploadSize int64 = 32 << 20 // 32MB +const defaultMaxUploadSize int64 = 5 << 30 // 5GB + +// maxMultipartMemory caps how much of a multipart upload is buffered in +// memory before spilling to temporary files on disk, regardless of +// maxUploadSize. +const maxMultipartMemory int64 = 32 << 20 // 32MB var indexHTML *template.Template var maxUploadSize int64 = defaultMaxUploadSize @@ -219,8 +224,8 @@ func handleMultipartUpload(w http.ResponseWriter, r *http.Request, start time.Ti r.Body = http.MaxBytesReader(w, r.Body, maxUploadSize) memoryLimit := maxUploadSize - if memoryLimit > defaultMaxUploadSize { - memoryLimit = defaultMaxUploadSize + if memoryLimit > maxMultipartMemory { + memoryLimit = maxMultipartMemory } if err := r.ParseMultipartForm(memoryLimit); err != nil {