diff --git a/api/http.go b/api/http.go index 0485261..08b59c1 100644 --- a/api/http.go +++ b/api/http.go @@ -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}) }