Skip to content

Commit

Permalink
Parse multipart form first
Browse files Browse the repository at this point in the history
  • Loading branch information
tvrg committed Jul 19, 2022
1 parent d4e7a9d commit 8a63a9f
Showing 1 changed file with 11 additions and 10 deletions.
21 changes: 11 additions & 10 deletions api/report.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,17 @@ import (
)

func (a *api) AddReport(ctx echo.Context, commitSha string, params AddReportParams) error {
r := ctx.Request()
err := r.ParseMultipartForm(200000)
if err != nil {
return echo.NewHTTPError(http.StatusBadRequest,
fmt.Sprintf("invalid multipart request: %s", err))
}

formdata := r.MultipartForm

files := formdata.File["report"]

commit, err := database.CreateOrGetCommit(a.db, model.Commit{CommitSha: commitSha})
if err != nil {
return err
Expand All @@ -27,16 +38,6 @@ func (a *api) AddReport(ctx echo.Context, commitSha string, params AddReportPara
return err
}

r := ctx.Request()
err = r.ParseMultipartForm(200000)
if err != nil {
return echo.NewHTTPError(http.StatusBadRequest,
fmt.Sprintf("invalid multipart request: %s", err))
}

formdata := r.MultipartForm

files := formdata.File["report"]

tests := []model.TestResult{}
for _, file := range files {
Expand Down

0 comments on commit 8a63a9f

Please sign in to comment.