Mercurial > gemma
diff pkg/controllers/srimports.go @ 1228:17131f0f9fcb
Added endpoint to explicitly delete a temp upload.
author | Sascha L. Teichmann <sascha.teichmann@intevation.de> |
---|---|
date | Mon, 19 Nov 2018 18:32:06 +0100 |
parents | 737e1acea1f1 |
children | d842d9d10872 |
line wrap: on
line diff
--- a/pkg/controllers/srimports.go Mon Nov 19 18:09:28 2018 +0100 +++ b/pkg/controllers/srimports.go Mon Nov 19 18:32:06 2018 +0100 @@ -34,6 +34,7 @@ "gemma.intevation.de/gemma/pkg/imports" "gemma.intevation.de/gemma/pkg/misc" "gemma.intevation.de/gemma/pkg/models" + "github.com/gorilla/mux" ) const ( @@ -193,7 +194,7 @@ // If there are no XYZ data we cant help the user anyway. if noXYZ { - code = status.StatusBadRequest + code = http.StatusBadRequest if err2 := os.RemoveAll(dir); err2 != nil { log.Printf("error: %v\n", err2) } @@ -212,3 +213,21 @@ } return } + +func deleteSoundingUpload(rw http.ResponseWriter, req *http.Request) { + token := mux.Vars(req)["token"] + if _, err := hex.DecodeString(token); err != nil { + http.Error(rw, "Invalid token", http.StatusBadRequest) + return + } + if err := misc.DeleteTempFile(token); err != nil { + http.Error(rw, fmt.Sprintf("error: %v", err), http.StatusInternalServerError) + return + } + result := struct { + Message string `json:"message"` + }{ + Message: fmt.Sprintf("Token %s deletes.", token), + } + SendJSON(rw, http.StatusOK, &result) +}