From 17b690673dd4f522d91e4a2d16e4fd5924d723a5 Mon Sep 17 00:00:00 2001 From: davrot Date: Mon, 27 Jan 2025 20:37:18 +0000 Subject: [PATCH] =?UTF-8?q?Dateien=20nach=20=E2=80=9Erouters/web=E2=80=9C?= =?UTF-8?q?=20hochladen?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- routers/web/web.go | 31 +++++++++++++++---------------- 1 file changed, 15 insertions(+), 16 deletions(-) diff --git a/routers/web/web.go b/routers/web/web.go index 81fa289e2e..93ca5ba828 100644 --- a/routers/web/web.go +++ b/routers/web/web.go @@ -51,12 +51,12 @@ import ( _ "code.gitea.io/gitea/modules/session" // to registers all internal adapters + "code.forgejo.org/go-chi/binding" "code.forgejo.org/go-chi/captcha" chi_middleware "github.com/go-chi/chi/v5/middleware" "github.com/go-chi/cors" "github.com/klauspost/compress/gzhttp" "github.com/prometheus/client_golang/prometheus" - "code.forgejo.org/go-chi/binding" ) var GzipMinSize = gzhttp.DefaultMinSize @@ -1674,19 +1674,18 @@ func registerRoutes(m *web.Route) { } func BindUpload(f forms.UploadRepoFileForm) http.HandlerFunc { - return func(resp http.ResponseWriter, req *http.Request) { - - theObj := new(forms.UploadRepoFileForm) // create a new form obj for every request but not use obj directly - data := middleware.GetContextData(req.Context()) - binding.Bind(req, theObj) - files := theObj.Files - var fullpaths []string - for _, fileID := range files { - fullPath := req.Form.Get("files_fullpath[" + fileID + "]") - fullpaths = append(fullpaths, fullPath) - } - theObj.FullPaths = fullpaths - data.GetData()["__form"] = theObj - middleware.AssignForm(theObj, data) - } + return func(resp http.ResponseWriter, req *http.Request) { + theObj := new(forms.UploadRepoFileForm) // create a new form obj for every request but not use obj directly + data := middleware.GetContextData(req.Context()) + binding.Bind(req, theObj) + files := theObj.Files + var fullpaths []string + for _, fileID := range files { + fullPath := req.Form.Get("files_fullpath[" + fileID + "]") + fullpaths = append(fullpaths, fullPath) + } + theObj.FullPaths = fullpaths + data.GetData()["__form"] = theObj + middleware.AssignForm(theObj, data) + } }