1
0
mirror of https://github.com/mgerb/go-discord-bot synced 2026-01-11 01:22:48 +00:00

convert file names to lowercase

This commit is contained in:
2017-08-22 17:57:18 -05:00
parent 6f89c7ce00
commit 892670c98b

View File

@@ -3,6 +3,7 @@ package handlers
import (
"io"
"os"
"strings"
"net/http"
@@ -41,6 +42,9 @@ func FileUpload(w http.ResponseWriter, r *http.Request) {
os.Mkdir(config.Config.SoundsPath, os.ModePerm)
}
// convert file name to lower case
header.Filename = strings.ToLower(header.Filename)
// check if file already exists
if _, err := os.Stat(config.Config.SoundsPath + header.Filename); err == nil {
response.ERR(w, http.StatusInternalServerError, []byte("File already exists."))