mirror of
https://codeberg.org/forgejo/forgejo.git
synced 2025-04-23 03:21:35 +02:00
Dateien nach „routers/web“ hochladen
This commit is contained in:
parent
4a20a897e4
commit
17b690673d
1 changed files with 15 additions and 16 deletions
|
@ -51,12 +51,12 @@ import (
|
||||||
|
|
||||||
_ "code.gitea.io/gitea/modules/session" // to registers all internal adapters
|
_ "code.gitea.io/gitea/modules/session" // to registers all internal adapters
|
||||||
|
|
||||||
|
"code.forgejo.org/go-chi/binding"
|
||||||
"code.forgejo.org/go-chi/captcha"
|
"code.forgejo.org/go-chi/captcha"
|
||||||
chi_middleware "github.com/go-chi/chi/v5/middleware"
|
chi_middleware "github.com/go-chi/chi/v5/middleware"
|
||||||
"github.com/go-chi/cors"
|
"github.com/go-chi/cors"
|
||||||
"github.com/klauspost/compress/gzhttp"
|
"github.com/klauspost/compress/gzhttp"
|
||||||
"github.com/prometheus/client_golang/prometheus"
|
"github.com/prometheus/client_golang/prometheus"
|
||||||
"code.forgejo.org/go-chi/binding"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
var GzipMinSize = gzhttp.DefaultMinSize
|
var GzipMinSize = gzhttp.DefaultMinSize
|
||||||
|
@ -1674,19 +1674,18 @@ func registerRoutes(m *web.Route) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func BindUpload(f forms.UploadRepoFileForm) http.HandlerFunc {
|
func BindUpload(f forms.UploadRepoFileForm) http.HandlerFunc {
|
||||||
return func(resp http.ResponseWriter, req *http.Request) {
|
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
|
||||||
theObj := new(forms.UploadRepoFileForm) // create a new form obj for every request but not use obj directly
|
data := middleware.GetContextData(req.Context())
|
||||||
data := middleware.GetContextData(req.Context())
|
binding.Bind(req, theObj)
|
||||||
binding.Bind(req, theObj)
|
files := theObj.Files
|
||||||
files := theObj.Files
|
var fullpaths []string
|
||||||
var fullpaths []string
|
for _, fileID := range files {
|
||||||
for _, fileID := range files {
|
fullPath := req.Form.Get("files_fullpath[" + fileID + "]")
|
||||||
fullPath := req.Form.Get("files_fullpath[" + fileID + "]")
|
fullpaths = append(fullpaths, fullPath)
|
||||||
fullpaths = append(fullpaths, fullPath)
|
}
|
||||||
}
|
theObj.FullPaths = fullpaths
|
||||||
theObj.FullPaths = fullpaths
|
data.GetData()["__form"] = theObj
|
||||||
data.GetData()["__form"] = theObj
|
middleware.AssignForm(theObj, data)
|
||||||
middleware.AssignForm(theObj, data)
|
}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue