From c5b8dbdeddbb0d0f2b95b6182f6792b38aab9fb5 Mon Sep 17 00:00:00 2001 From: Hugh Bord Date: Tue, 12 Dec 2023 17:03:26 +0800 Subject: [PATCH] make files dir if it doesn't exist --- main.go | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/main.go b/main.go index e065e3a..0b7639f 100644 --- a/main.go +++ b/main.go @@ -276,6 +276,11 @@ func main() { return nil }) + // Create the files directory if it doesn't already exist + if _, err := os.Stat(conf.FileFolder); os.IsNotExist(err) { + os.Mkdir(conf.FileFolder, 0755) + } + r := mux.NewRouter() r.HandleFunc("/", UploadHandler).Methods("POST") r.HandleFunc("/uploads/{name}", func(w http.ResponseWriter, r *http.Request) {