Increase default max upload size to 5GB

This commit is contained in:
2026-08-29 00:50:43 +02:00
parent 00920d42ef
commit 34b90c62ca
+8 -3
View File
@@ -27,7 +27,12 @@ const idLength = 8
const idCharset = "abcdefghijklmnopqrstuvwxyz0123456789" const idCharset = "abcdefghijklmnopqrstuvwxyz0123456789"
// defaultMaxUploadSize is used when MAX_UPLOAD_SIZE is not set. // 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 indexHTML *template.Template
var maxUploadSize int64 = defaultMaxUploadSize 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) r.Body = http.MaxBytesReader(w, r.Body, maxUploadSize)
memoryLimit := maxUploadSize memoryLimit := maxUploadSize
if memoryLimit > defaultMaxUploadSize { if memoryLimit > maxMultipartMemory {
memoryLimit = defaultMaxUploadSize memoryLimit = maxMultipartMemory
} }
if err := r.ParseMultipartForm(memoryLimit); err != nil { if err := r.ParseMultipartForm(memoryLimit); err != nil {