|
|
|
@ -19,12 +19,6 @@ import ( |
|
|
|
"fssc/web" |
|
|
|
) |
|
|
|
|
|
|
|
// rpc功能 压缩包的结构体
|
|
|
|
// 文件路径 文件名
|
|
|
|
type Args struct { |
|
|
|
Zpfile, Fname string |
|
|
|
} |
|
|
|
|
|
|
|
// 获取文件大小的接口
|
|
|
|
type Size interface { |
|
|
|
Size() int64 |
|
|
|
@ -35,31 +29,6 @@ type Stat interface { |
|
|
|
Stat() (os.FileInfo, error) |
|
|
|
} |
|
|
|
|
|
|
|
// 显示状态
|
|
|
|
func ReceiveStatus(w http.ResponseWriter, r *http.Request) { |
|
|
|
switch r.Method { |
|
|
|
// 显示当前传送文件的大小
|
|
|
|
case http.MethodPost: |
|
|
|
file, _, err := r.FormFile("file") |
|
|
|
if err != nil { |
|
|
|
http.Error(w, err.Error(), 500) |
|
|
|
return |
|
|
|
} |
|
|
|
|
|
|
|
if statInterface, ok := file.(Stat); ok { |
|
|
|
fileInfo, _ := statInterface.Stat() |
|
|
|
fmt.Fprintf(w, "上传文件的大小为: %d", fileInfo.Size()) |
|
|
|
} |
|
|
|
|
|
|
|
if sizeInterface, ok := file.(Size); ok { |
|
|
|
fmt.Fprintf(w, "上传文件的大小为: %d", sizeInterface.Size()) |
|
|
|
} |
|
|
|
return |
|
|
|
} |
|
|
|
|
|
|
|
// fmt.Fprintf(w, r.Method)
|
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
** 文件更新服务器 |
|
|
|
**/ |
|
|
|
@ -210,6 +179,7 @@ func SendHandler(w http.ResponseWriter, r *http.Request) { |
|
|
|
|
|
|
|
data := struct { |
|
|
|
DeviceName string |
|
|
|
Loip string |
|
|
|
Rundir string |
|
|
|
IsDir bool |
|
|
|
FileName string |
|
|
|
@ -218,6 +188,7 @@ func SendHandler(w http.ResponseWriter, r *http.Request) { |
|
|
|
Files []os.DirEntry |
|
|
|
}{ |
|
|
|
DeviceName: config.G.DeviceName, |
|
|
|
Loip: config.G.LocalIP, |
|
|
|
Rundir: config.G.FilePath, |
|
|
|
DownloadPath: downloadPath, |
|
|
|
UrlPath: strings.TrimSuffix(r.URL.Path, "/"), |
|
|
|
|