Browse Source

Update upload pipeline validation

feature/update-route-registration
Roman Zipp 3 years ago
committed by Fabian Vowie
parent
commit
af04ff1dc9
No known key found for this signature in database GPG Key ID: C27317C33B27C410
  1. 18
      main.go

18
main.go

@ -11,7 +11,6 @@ import (
"github.com/spf13/afero" "github.com/spf13/afero"
"io" "io"
"net/http" "net/http"
"strings"
) )
const Name string = "Lithium" const Name string = "Lithium"
@ -56,12 +55,25 @@ func UploadHandler(w http.ResponseWriter, r *http.Request, pipes []pipelines.IPi
defer formFile.Close() defer formFile.Close()
// check pipelines form param // check pipelines form param
formPipelines := strings.Split(r.FormValue("pipelines"), ",")
if len(formPipelines) == 0 {
formPipeline := r.FormValue("pipeline")
if formPipeline == "" {
writeError(w, http.StatusUnprocessableEntity, "pipeline parameter missing") writeError(w, http.StatusUnprocessableEntity, "pipeline parameter missing")
return return
} }
var execPipe pipelines.IPipeline
for _, pipe := range pipes {
if formPipeline == pipe.GetSlug() {
execPipe = pipe
break
}
}
if execPipe == nil {
writeError(w, http.StatusUnprocessableEntity, "pipeline not found")
return
}
bucket := r.FormValue("bucket") bucket := r.FormValue("bucket")
if bucket == "" { if bucket == "" {
writeError(w, http.StatusUnprocessableEntity, "bucket parameter missing") writeError(w, http.StatusUnprocessableEntity, "bucket parameter missing")

Loading…
Cancel
Save