mirror of
https://github.com/duanhf2012/origin.git
synced 2026-05-22 18:07:33 +08:00
文件判断修改
This commit is contained in:
@@ -408,12 +408,12 @@ func staticServer(routerUrl string, routerData RouterStaticResoutceData, w http.
|
|||||||
defer resourceFile.Close()
|
defer resourceFile.Close()
|
||||||
//重新拼接文件名
|
//重新拼接文件名
|
||||||
imgFormat := strings.Split(resourceFileHeader.Filename, ".")
|
imgFormat := strings.Split(resourceFileHeader.Filename, ".")
|
||||||
if len(imgFormat) != 2 {
|
if len(imgFormat) < 2 {
|
||||||
writeResp(http.StatusNotFound, "not a file")
|
writeResp(http.StatusNotFound, "not a file")
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
filePrefixName := uuid.Rand().HexEx()
|
filePrefixName := uuid.Rand().HexEx()
|
||||||
fileName := filePrefixName + "." + imgFormat[1]
|
fileName := filePrefixName + "." + imgFormat[len(imgFormat)-1]
|
||||||
//创建文件
|
//创建文件
|
||||||
localpath := fmt.Sprintf("%s%s", destLocalPath, fileName)
|
localpath := fmt.Sprintf("%s%s", destLocalPath, fileName)
|
||||||
localfd, err := os.OpenFile(localpath, os.O_WRONLY|os.O_CREATE, 0666)
|
localfd, err := os.OpenFile(localpath, os.O_WRONLY|os.O_CREATE, 0666)
|
||||||
|
|||||||
Reference in New Issue
Block a user