|
|
@ -52,13 +52,11 @@ func main() { |
|
|
} |
|
|
} |
|
|
defer client.rpcClient.Close() |
|
|
defer client.rpcClient.Close() |
|
|
// 调用 transferFile
|
|
|
// 调用 transferFile
|
|
|
// err = transferFile(client, *curPath, *uploadPath)
|
|
|
err = transferFile(client, *curPath, *uploadPath) |
|
|
// if err != nil {
|
|
|
if err != nil { |
|
|
// logger.Error("TransferFile failed", zap.Error(err))
|
|
|
logger.Error("TransferFile failed", zap.Error(err)) |
|
|
// fmt.Printf("TransferFile failed: %v\n", err)
|
|
|
} |
|
|
// }
|
|
|
|
|
|
// fmt.Printf("TransferFile success\n")
|
|
|
// fmt.Printf("TransferFile success\n")
|
|
|
transferFile(client, *curPath, *uploadPath) |
|
|
|
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
// 创建新的客户端
|
|
|
// 创建新的客户端
|
|
|
@ -83,18 +81,8 @@ func transferFile(c *UpFileClient, curPath string, uploadPath string) error { |
|
|
return err |
|
|
return err |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
// 提取文件名
|
|
|
|
|
|
// 远程的文件名
|
|
|
|
|
|
// fileName := filepath.Base(uploadPath)
|
|
|
|
|
|
// fmt.Printf("fileName: %s\n", fileName)
|
|
|
|
|
|
|
|
|
|
|
|
// 远程服务器的路径
|
|
|
|
|
|
// dirpath := filepath.Dir(uploadPath)
|
|
|
|
|
|
// fmt.Printf("remote dirpath: %s\n", dirpath)
|
|
|
|
|
|
// fmt.Printf("file size: %d\n", fileInfo.Size())
|
|
|
|
|
|
|
|
|
|
|
|
// 异步
|
|
|
// 异步
|
|
|
// go func() {
|
|
|
go func() { |
|
|
// 发送文件信息
|
|
|
// 发送文件信息
|
|
|
var reply string |
|
|
var reply string |
|
|
c.rpcClient.Call("UpFileService.SendFileInfo", FileInfo{ |
|
|
c.rpcClient.Call("UpFileService.SendFileInfo", FileInfo{ |
|
|
@ -103,7 +91,7 @@ func transferFile(c *UpFileClient, curPath string, uploadPath string) error { |
|
|
}, &reply) |
|
|
}, &reply) |
|
|
// 输出执行的结果
|
|
|
// 输出执行的结果
|
|
|
fmt.Printf("SendFileInfo result: %v\n", reply) |
|
|
fmt.Printf("SendFileInfo result: %v\n", reply) |
|
|
// }()
|
|
|
}() |
|
|
|
|
|
|
|
|
return nil |
|
|
return nil |
|
|
} |
|
|
} |
|
|
|