diff options
| author | Heinrich 'Henrik' Langos <gumbo2000@noreply@mills.io> | 2023-01-22 03:34:03 +0100 |
|---|---|---|
| committer | Heinrich 'Henrik' Langos <gumbo2000@noreply@mills.io> | 2023-02-12 16:58:36 +0100 |
| commit | 4e60bfcf056bbbdab5d75fcfc406b6c7c07e1bff (patch) | |
| tree | 731398fc558f48e9236fa4e225666e0296693308 /app/app.go | |
| parent | 7e6e2a0c1c2c20ca2b5bd1434e1c335a32b13330 (diff) | |
Fix upload error for large filesfix-large-upload-buffer
This should avoid allocation of max_upload_size bytes of RAM.
Instead we only allocate 1MB of RAM for the upload form decoder.
- Fixes #67
Diffstat (limited to 'app/app.go')
| -rw-r--r-- | app/app.go | 5 |
1 files changed, 4 insertions, 1 deletions
@@ -42,6 +42,9 @@ type App struct { Router *mux.Router } +// 1MB buffer in RAM seems enough +const uploadParserBuffer = 1_048_576 + // NewApp returns a new instance of App from Config. func NewApp(cfg *Config) (*App, error) { if cfg == nil { @@ -234,7 +237,7 @@ func (a *App) uploadHandler(w http.ResponseWriter, r *http.Request) { } a.render("upload", w, ctx) } else if r.Method == "POST" { - r.ParseMultipartForm(a.Config.Server.MaxUploadSize) + r.ParseMultipartForm(uploadParserBuffer) file, handler, err := r.FormFile("video_file") if err != nil { |
