|
|
@ -120,7 +120,7 @@ func Supfile(w http.ResponseWriter, r *http.Request) { |
|
|
// 替换 反斜杠
|
|
|
// 替换 反斜杠
|
|
|
bbpath := strings.Replace(bpath, "/", "\\", -1) |
|
|
bbpath := strings.Replace(bpath, "/", "\\", -1) |
|
|
// 拼装, 文件的实际地址
|
|
|
// 拼装, 文件的实际地址
|
|
|
ziprl := filepath.Join(config.G.FilePath, bbpath, "/", bfile) |
|
|
ziprl := filepath.Join(config.G.FilePath, "/", bbpath, "/", bfile) |
|
|
|
|
|
|
|
|
// 创建udp 渠道发送数据
|
|
|
// 创建udp 渠道发送数据
|
|
|
message := fmt.Sprintf("%s%s%s", "xdml|", bbpath, "|sender") |
|
|
message := fmt.Sprintf("%s%s%s", "xdml|", bbpath, "|sender") |
|
|
@ -129,26 +129,6 @@ func Supfile(w http.ResponseWriter, r *http.Request) { |
|
|
|
|
|
|
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
// 文件服务
|
|
|
|
|
|
func FileServerHandler(w http.ResponseWriter, r *http.Request) { |
|
|
|
|
|
currentPath := config.G.FilePath |
|
|
|
|
|
|
|
|
|
|
|
fileInfo, err := os.Stat(currentPath) |
|
|
|
|
|
if err != nil { |
|
|
|
|
|
http.Error(w, err.Error(), http.StatusInternalServerError) |
|
|
|
|
|
return |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
basePath := filepath.Base(currentPath) |
|
|
|
|
|
if fileInfo.IsDir() { |
|
|
|
|
|
path := r.URL.Path[len("/download/"+basePath):] |
|
|
|
|
|
fullPath := filepath.Join(currentPath, path) |
|
|
|
|
|
http.ServeFile(w, r, fullPath) |
|
|
|
|
|
} else { |
|
|
|
|
|
http.ServeFile(w, r, currentPath) |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// udp 方式发送zip文件
|
|
|
// udp 方式发送zip文件
|
|
|
func SendZip(w http.ResponseWriter, r *http.Request) { |
|
|
func SendZip(w http.ResponseWriter, r *http.Request) { |
|
|
r.ParseForm() |
|
|
r.ParseForm() |
|
|
|