Skip to content

Commit

Permalink
Merge pull request #45 from grisu48/post
Browse files Browse the repository at this point in the history
Fix upload not working issue
  • Loading branch information
grisu48 authored Aug 9, 2022
2 parents fb036c4 + 9218427 commit 0e93e01
Showing 1 changed file with 14 additions and 13 deletions.
27 changes: 14 additions & 13 deletions cmd/pastad/pastad.go
Original file line number Diff line number Diff line change
Expand Up @@ -390,21 +390,22 @@ func ReceivePasta(r *http.Request) (Pasta, error) {
pasta.Id = ""
return pasta, err
}
}
// Check if the input is coming from the POST form
inputs := r.URL.Query()["input"]
if len(inputs) > 0 && inputs[0] == "form" {
// Copy reader, as r.FromValue consumes it's contents
defer r.Body.Close()
reader = r.Body
if content := r.FormValue("content"); content != "" {
reader = io.NopCloser(strings.NewReader(content))
} else {
// Check if the input is coming from the POST form
inputs := r.URL.Query()["input"]
if len(inputs) > 0 && inputs[0] == "form" {
// Copy reader, as r.FromValue consumes it's contents
defer r.Body.Close()
reader = r.Body
if content := r.FormValue("content"); content != "" {
reader = io.NopCloser(strings.NewReader(content))
} else {
pasta.Id = "" // Empty pasta
return pasta, nil
}
} else {
pasta.Id = "" // Empty pasta
return pasta, nil
reader = r.Body
}
} else {
reader = r.Body
}
defer reader.Close()

Expand Down

0 comments on commit 0e93e01

Please sign in to comment.