Skip to content

Commit

Permalink
fix: stream http request instead of consuming all
Browse files Browse the repository at this point in the history
  • Loading branch information
adamdecaf committed Dec 7, 2023
1 parent 19dff26 commit 816d6bb
Showing 1 changed file with 1 addition and 9 deletions.
10 changes: 1 addition & 9 deletions pkg/server/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,8 @@
package server

import (
"bytes"
"encoding/json"
"errors"
"io"
"net/http"
"strings"

Expand All @@ -20,15 +18,9 @@ import (
func parseInputFromRequest(r *http.Request) (file.File, error) {
src, _, err := r.FormFile("file")
if err != nil {

buf, err := io.ReadAll(r.Body)
if err != nil {
return nil, errors.New("unable to read request body")
}

defer r.Body.Close()

mf, err := file.NewFileFromReader(bytes.NewReader(buf))
mf, err := file.NewFileFromReader(r.Body)
if err != nil {
return nil, err
}
Expand Down

0 comments on commit 816d6bb

Please sign in to comment.