diff options
author | Ollie Phillips <oliver@eantics.co.uk> | 2019-03-25 22:20:32 +0000 |
---|---|---|
committer | Ollie Phillips <oliver@eantics.co.uk> | 2019-03-25 22:20:32 +0000 |
commit | 20da628b140cd90b5937c412a8fa6670389bff38 (patch) | |
tree | 5faeba2f04e27b971b4a6b6c810c9087258e4b82 /system | |
parent | df5b487fec9bdc6b98fc6cbc60c45e360d18eeb4 (diff) |
dev
Diffstat (limited to 'system')
-rw-r--r-- | system/admin/handlers.go | 18 |
1 files changed, 16 insertions, 2 deletions
diff --git a/system/admin/handlers.go b/system/admin/handlers.go index ba16998..c47755f 100644 --- a/system/admin/handlers.go +++ b/system/admin/handlers.go @@ -8,6 +8,7 @@ import ( "fmt" "log" "net/http" + "os" "strconv" "strings" "time" @@ -2201,15 +2202,28 @@ func deleteUploadHandler(res http.ResponseWriter, req *http.Request) { } // get upload data - upload, err := db.Upload(t + ":" + id) + upload := item.FileUpload{} + data, err := db.Upload(t + ":" + id) if err != nil { log.Println(err) res.WriteHeader(http.StatusInternalServerError) return } + if err = json.Unmarshal(data, &upload); err != nil { + log.Println(err) + res.WriteHeader(http.StatusInternalServerError) + return + } + // use path to delete the physical file from disk - log.Println("file data:", string(upload)) + delPath := strings.Replace(upload.Path, "/api/", "./", 1) + err = os.Remove(delPath) + if err != nil { + log.Println(err) + res.WriteHeader(http.StatusInternalServerError) + return + } err = db.DeleteUpload(t + ":" + id) if err != nil { |