添加用户缓存及更新,添加配置文件增删改查接口,添加文件功能.添加配置文件添加正则匹配路径
This commit is contained in:
parent
2320a997b4
commit
f22df7f012
|
|
@ -9,6 +9,7 @@ import (
|
||||||
"mime/multipart"
|
"mime/multipart"
|
||||||
"os"
|
"os"
|
||||||
"path"
|
"path"
|
||||||
|
"regexp"
|
||||||
"time"
|
"time"
|
||||||
"videoplayer/dao"
|
"videoplayer/dao"
|
||||||
"videoplayer/proto"
|
"videoplayer/proto"
|
||||||
|
|
@ -83,6 +84,13 @@ func CreateConfigFile(req *proto.ConfigFileReq, userId int) error {
|
||||||
}
|
}
|
||||||
//查看系统中是否存在文件,不存在则创建
|
//查看系统中是否存在文件,不存在则创建
|
||||||
file := req.FilePath + "/" + req.FileName
|
file := req.FilePath + "/" + req.FileName
|
||||||
|
//正则判断文件名是否合法
|
||||||
|
pattern := `^/([^/:\*?]+/)*([^/:\*?]+)?$`
|
||||||
|
reg := regexp.MustCompile(pattern)
|
||||||
|
if reg.MatchString(file) == false {
|
||||||
|
err = fmt.Errorf("file path is invalid")
|
||||||
|
return err
|
||||||
|
}
|
||||||
_, err = os.Stat(file)
|
_, err = os.Stat(file)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
//创建文件
|
//创建文件
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue