Add url to upload response
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful

This commit is contained in:
Torjus Håkestad 2022-01-24 19:03:20 +01:00
parent bde2a38931
commit b559d28a38

View File

@ -4,6 +4,7 @@ import (
"encoding/json"
"io"
"net/http"
"path"
"strconv"
"strings"
"time"
@ -84,6 +85,7 @@ func (s *HTTPServer) HandlerAPIFilePost(w http.ResponseWriter, r *http.Request)
return
}
s.Logger.Infow("Stored file.", "req_id", reqID, "id", f.ID, "remote_addr", r.RemoteAddr)
fileURL := path.Join(s.config.URL, "/api/file", f.ID)
var resp = struct {
Message string `json:"message"`
ID string `json:"id"`
@ -91,7 +93,7 @@ func (s *HTTPServer) HandlerAPIFilePost(w http.ResponseWriter, r *http.Request)
}{
Message: "OK",
ID: f.ID,
URL: "TODO",
URL: fileURL,
}
w.WriteHeader(http.StatusAccepted)
encoder := json.NewEncoder(w)
@ -164,7 +166,8 @@ func (s *HTTPServer) processMultiPartFormUpload(w http.ResponseWriter, r *http.R
}
s.Logger.Infow("Stored file.", "req_id", reqID, "id", f.ID, "filename", f.OriginalFilename, "remote_addr", r.RemoteAddr)
responses = append(responses, ResponseAPIFilePost{Message: "OK", ID: f.ID, URL: "TODO"})
fileURL := path.Join(s.config.URL, "/api/file", f.ID)
responses = append(responses, ResponseAPIFilePost{Message: "OK", ID: f.ID, URL: fileURL})
}