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) {
|
||||
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"))
|
||||
if err != nil {
|
||||
utils.HttpBadRequest(w, "No X coordinate received.")
|
||||
@ -31,11 +38,6 @@ func (h *RoomHandler) uploadDrop(w http.ResponseWriter, r *http.Request) {
|
||||
return
|
||||
}
|
||||
|
||||
if r.MultipartForm == nil {
|
||||
utils.HttpBadRequest(w, "No MultipartForm received.")
|
||||
return
|
||||
}
|
||||
|
||||
req_files := r.MultipartForm.File["files"]
|
||||
if len(req_files) == 0 {
|
||||
utils.HttpBadRequest(w, "No files received.")
|
||||
@ -77,8 +79,10 @@ func (h *RoomHandler) uploadDrop(w http.ResponseWriter, r *http.Request) {
|
||||
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)
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user