|
|
|
@ -1,7 +1,6 @@ |
|
|
|
package handler |
|
|
|
|
|
|
|
import ( |
|
|
|
"encoding/json" |
|
|
|
"fmt" |
|
|
|
"html/template" |
|
|
|
"io" |
|
|
|
@ -166,10 +165,10 @@ func SendZip(w http.ResponseWriter, r *http.Request) { |
|
|
|
} |
|
|
|
|
|
|
|
// 选中的路径,可以为空
|
|
|
|
wtculpath := r.Form["curpath"] |
|
|
|
//wtculpath := r.Form["curpath"]
|
|
|
|
|
|
|
|
// 实际路径
|
|
|
|
realFilePath := filepath.Join(config.G.FilePath, wtculpath[0]) |
|
|
|
realFilePath := filepath.Join(config.G.FilePath, "") |
|
|
|
|
|
|
|
// zip 文件名
|
|
|
|
zpFileName := "BIU_" + time.Now().Format("20060102_150405") + ".zip" |
|
|
|
@ -278,35 +277,7 @@ func SendHandler(w http.ResponseWriter, r *http.Request) { |
|
|
|
if err != nil { |
|
|
|
http.Error(w, err.Error(), http.StatusInternalServerError) |
|
|
|
} |
|
|
|
case http.MethodPost: |
|
|
|
// return file or folder information in JSON format for convenient send to the recipient
|
|
|
|
currentPath := config.G.FilePath |
|
|
|
fileInfo, err := os.Stat(currentPath) |
|
|
|
if err != nil { |
|
|
|
http.Error(w, err.Error(), http.StatusInternalServerError) |
|
|
|
return |
|
|
|
} |
|
|
|
|
|
|
|
var pathInfo struct { |
|
|
|
Type string `json:"type"` |
|
|
|
Paths []string `json:"paths"` |
|
|
|
} |
|
|
|
|
|
|
|
if fileInfo.IsDir() { |
|
|
|
files, err := util.GetDirFilePaths(currentPath, true) |
|
|
|
if err != nil { |
|
|
|
http.Error(w, err.Error(), http.StatusInternalServerError) |
|
|
|
return |
|
|
|
} |
|
|
|
pathInfo.Paths = files |
|
|
|
pathInfo.Type = "dir" |
|
|
|
} else { |
|
|
|
pathInfo.Paths = []string{filepath.Base(currentPath)} |
|
|
|
pathInfo.Type = "file" |
|
|
|
} |
|
|
|
|
|
|
|
w.Header().Set("Content-Type", "application/json") |
|
|
|
json.NewEncoder(w).Encode(pathInfo) |
|
|
|
default: |
|
|
|
http.Error(w, "Method not allowed", http.StatusMethodNotAllowed) |
|
|
|
} |
|
|
|
|