mirror of
https://github.com/m1k1o/neko.git
synced 2024-07-24 14:40:50 +12:00
multipart form correct destroying.
This commit is contained in:
parent
a96b770052
commit
8c47cbae68
@ -19,6 +19,13 @@ const (
|
|||||||
func (h *RoomHandler) uploadDrop(w http.ResponseWriter, r *http.Request) {
|
func (h *RoomHandler) uploadDrop(w http.ResponseWriter, r *http.Request) {
|
||||||
r.ParseMultipartForm(MAX_UPLOAD_SIZE)
|
r.ParseMultipartForm(MAX_UPLOAD_SIZE)
|
||||||
|
|
||||||
|
if r.MultipartForm == nil {
|
||||||
|
utils.HttpBadRequest(w, "No MultipartForm received.")
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
defer r.MultipartForm.RemoveAll()
|
||||||
|
|
||||||
X, err := strconv.Atoi(r.FormValue("x"))
|
X, err := strconv.Atoi(r.FormValue("x"))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
utils.HttpBadRequest(w, "No X coordinate received.")
|
utils.HttpBadRequest(w, "No X coordinate received.")
|
||||||
@ -31,11 +38,6 @@ func (h *RoomHandler) uploadDrop(w http.ResponseWriter, r *http.Request) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
if r.MultipartForm == nil {
|
|
||||||
utils.HttpBadRequest(w, "No MultipartForm received.")
|
|
||||||
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 files received.")
|
utils.HttpBadRequest(w, "No files received.")
|
||||||
@ -77,8 +79,10 @@ func (h *RoomHandler) uploadDrop(w http.ResponseWriter, r *http.Request) {
|
|||||||
files = append(files, path)
|
files = append(files, path)
|
||||||
}
|
}
|
||||||
|
|
||||||
h.desktop.DropFiles(X, Y, files)
|
if !h.desktop.DropFiles(X, Y, files) {
|
||||||
|
utils.HttpInternalServerError(w, "Unable to drop files.")
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
r.MultipartForm.RemoveAll()
|
|
||||||
utils.HttpSuccess(w)
|
utils.HttpSuccess(w)
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user