make files dir if it doesn't exist

This commit is contained in:
Hugh Bord 2023-12-12 17:03:26 +08:00
parent cb270d1e16
commit c5b8dbdedd

View File

@ -276,6 +276,11 @@ func main() {
return nil 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 := mux.NewRouter()
r.HandleFunc("/", UploadHandler).Methods("POST") r.HandleFunc("/", UploadHandler).Methods("POST")
r.HandleFunc("/uploads/{name}", func(w http.ResponseWriter, r *http.Request) { r.HandleFunc("/uploads/{name}", func(w http.ResponseWriter, r *http.Request) {