diff options
Diffstat (limited to 'workhorse/internal/upload/accelerate.go')
-rw-r--r-- | workhorse/internal/upload/accelerate.go | 11 |
1 files changed, 8 insertions, 3 deletions
diff --git a/workhorse/internal/upload/accelerate.go b/workhorse/internal/upload/accelerate.go index 81f44d33a82..28d3b3dee2e 100644 --- a/workhorse/internal/upload/accelerate.go +++ b/workhorse/internal/upload/accelerate.go @@ -17,16 +17,21 @@ type MultipartClaims struct { jwt.StandardClaims } -func Accelerate(rails PreAuthorizer, h http.Handler, p Preparer) http.Handler { +// Multipart is a request middleware. If the request has a MIME multipart +// request body, the middleware will iterate through the multipart parts. +// When it finds a file part (filename != ""), the middleware will save +// the file contents to a temporary location and replace the file part +// with a reference to the temporary location. +func Multipart(rails PreAuthorizer, h http.Handler, p Preparer) http.Handler { return rails.PreAuthorizeHandler(func(w http.ResponseWriter, r *http.Request, a *api.Response) { s := &SavedFileTracker{Request: r} opts, _, err := p.Prepare(a) if err != nil { - helper.Fail500(w, r, fmt.Errorf("Accelerate: error preparing file storage options")) + helper.Fail500(w, r, fmt.Errorf("Multipart: error preparing file storage options")) return } - HandleFileUploads(w, r, h, a, s, opts) + InterceptMultipartFiles(w, r, h, a, s, opts) }, "/authorize") } |