update upload API error reporting & cleanup.

This commit is contained in:
Miroslav Šedivý 2021-01-09 16:24:05 +01:00
parent fad6b649d3
commit 9f3bc0261c

View File

@ -21,19 +21,24 @@ func (h *RoomHandler) uploadDrop(w http.ResponseWriter, r *http.Request) {
X, err := strconv.Atoi(r.FormValue("x")) X, err := strconv.Atoi(r.FormValue("x"))
if err != nil { if err != nil {
utils.HttpBadRequest(w, err) utils.HttpBadRequest(w, "No X coordinate received.")
return return
} }
Y, err := strconv.Atoi(r.FormValue("y")) Y, err := strconv.Atoi(r.FormValue("y"))
if err != nil { if err != nil {
utils.HttpBadRequest(w, err) utils.HttpBadRequest(w, "No Y coordinate received.")
return
}
if r.MultipartForm == nil {
utils.HttpBadRequest(w, "No MultipartForm received.")
return return
} }
req_files := r.MultipartForm.File["files"] req_files := r.MultipartForm.File["files"]
if len(req_files) == 0 { if len(req_files) == 0 {
utils.HttpBadRequest(w, "No file received.") utils.HttpBadRequest(w, "No files received.")
return return
} }
@ -73,5 +78,7 @@ func (h *RoomHandler) uploadDrop(w http.ResponseWriter, r *http.Request) {
} }
h.desktop.DropFiles(X, Y, files) h.desktop.DropFiles(X, Y, files)
r.MultipartForm.RemoveAll()
utils.HttpSuccess(w) utils.HttpSuccess(w)
} }