Increase upload multipart limit for raw export bundles
This commit is contained in:
@@ -14,6 +14,7 @@ import (
|
|||||||
"path/filepath"
|
"path/filepath"
|
||||||
"regexp"
|
"regexp"
|
||||||
"sort"
|
"sort"
|
||||||
|
"strconv"
|
||||||
"strings"
|
"strings"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
@@ -46,8 +47,7 @@ func (s *Server) handleIndex(w http.ResponseWriter, r *http.Request) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (s *Server) handleUpload(w http.ResponseWriter, r *http.Request) {
|
func (s *Server) handleUpload(w http.ResponseWriter, r *http.Request) {
|
||||||
// Max 100MB file
|
if err := r.ParseMultipartForm(uploadMultipartMaxBytes()); err != nil {
|
||||||
if err := r.ParseMultipartForm(100 << 20); err != nil {
|
|
||||||
jsonError(w, "File too large", http.StatusBadRequest)
|
jsonError(w, "File too large", http.StatusBadRequest)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@@ -143,6 +143,29 @@ func (s *Server) handleUpload(w http.ResponseWriter, r *http.Request) {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func uploadMultipartMaxBytes() int64 {
|
||||||
|
// Large Redfish raw bundles can easily exceed 100 MiB once raw trees and logs
|
||||||
|
// are embedded. Keep the default high but bounded for a normal workstation.
|
||||||
|
const (
|
||||||
|
defMB = 512
|
||||||
|
minMB = 100
|
||||||
|
maxMB = 2048
|
||||||
|
)
|
||||||
|
mb := defMB
|
||||||
|
if v := strings.TrimSpace(os.Getenv("LOGPILE_UPLOAD_MAX_MB")); v != "" {
|
||||||
|
if n, err := strconv.Atoi(v); err == nil {
|
||||||
|
if n < minMB {
|
||||||
|
n = minMB
|
||||||
|
}
|
||||||
|
if n > maxMB {
|
||||||
|
n = maxMB
|
||||||
|
}
|
||||||
|
mb = n
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return int64(mb) << 20
|
||||||
|
}
|
||||||
|
|
||||||
func (s *Server) reanalyzeRawExportPackage(pkg *RawExportPackage) (*models.AnalysisResult, string, error) {
|
func (s *Server) reanalyzeRawExportPackage(pkg *RawExportPackage) (*models.AnalysisResult, string, error) {
|
||||||
if pkg == nil {
|
if pkg == nil {
|
||||||
return nil, "", fmt.Errorf("empty package")
|
return nil, "", fmt.Errorf("empty package")
|
||||||
|
|||||||
Reference in New Issue
Block a user