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 12:23:49 +0100 |
| commit | adfb9023c2fd00ec14ea753b49334bd5b9b00c57 (patch) | |
| tree | 321af01587e0f5ae0bcaee4fc2844249931a5e0c /app | |
| parent | c9ae0f31f0ec016a53b314507af1fa8c7aaa1f9e (diff) | |
Fix upload error for large files
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')
| -rw-r--r-- | app/app.go | 7 |
1 files changed, 4 insertions, 3 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 { @@ -235,9 +238,7 @@ func (a *App) uploadHandler(respWriter http.ResponseWriter, request *http.Reques a.renderUploadPage(respWriter) } else if request.Method == "POST" { - // The number here is probably used in the wrong place. - // Why should we expect tube to fit all uploads into memory? - request.ParseMultipartForm(a.Config.Server.MaxUploadSize) + request.ParseMultipartForm(uploadParserBuffer) // get information from the upload form and make sure it is valid videoTitleFromUpload := request.FormValue("video_title") |
