mirror of
https://github.com/mgerb/go-discord-bot
synced 2026-01-11 09:32:50 +00:00
convert file names to lowercase
This commit is contained in:
@@ -3,6 +3,7 @@ package handlers
|
|||||||
import (
|
import (
|
||||||
"io"
|
"io"
|
||||||
"os"
|
"os"
|
||||||
|
"strings"
|
||||||
|
|
||||||
"net/http"
|
"net/http"
|
||||||
|
|
||||||
@@ -41,6 +42,9 @@ func FileUpload(w http.ResponseWriter, r *http.Request) {
|
|||||||
os.Mkdir(config.Config.SoundsPath, os.ModePerm)
|
os.Mkdir(config.Config.SoundsPath, os.ModePerm)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// convert file name to lower case
|
||||||
|
header.Filename = strings.ToLower(header.Filename)
|
||||||
|
|
||||||
// check if file already exists
|
// check if file already exists
|
||||||
if _, err := os.Stat(config.Config.SoundsPath + header.Filename); err == nil {
|
if _, err := os.Stat(config.Config.SoundsPath + header.Filename); err == nil {
|
||||||
response.ERR(w, http.StatusInternalServerError, []byte("File already exists."))
|
response.ERR(w, http.StatusInternalServerError, []byte("File already exists."))
|
||||||
|
|||||||
Reference in New Issue
Block a user