|
|
|
@ -114,9 +114,10 @@ func (f *FileService) Compress(args *ZipBlock, reply *string) error { |
|
|
|
// 如果压缩包生成成功以后再执行
|
|
|
|
if strings.EqualFold(strings.ToLower(rest), "arcok") { |
|
|
|
// 合并为实际路径
|
|
|
|
remotePath := path.Join("/www/wwwroot", args.RemotePath, zpFileName) |
|
|
|
// remotePath := path.Join("/www/wwwroot", args.RemotePath, zpFileName)
|
|
|
|
// 异步发送文件到远程服务器上
|
|
|
|
go clientUploadFile(args.RemoteAddr, ziprl, remotePath) |
|
|
|
// go clientUploadFile(args.RemoteAddr, ziprl, remotePath)
|
|
|
|
go clientUploadFile(args.RemoteAddr, ziprl) |
|
|
|
|
|
|
|
// 返回压缩包名称
|
|
|
|
*reply = ziprl |
|
|
|
@ -127,7 +128,7 @@ func (f *FileService) Compress(args *ZipBlock, reply *string) error { |
|
|
|
|
|
|
|
// 客户端调用RPC传送文件的函数
|
|
|
|
// 传入zip的实际路径,远程的服务器带端口,远程文件存放路径
|
|
|
|
func clientUploadFile(remote string, filePath string, uploadPath string) error { |
|
|
|
func clientUploadFile(remote string, filePath string) error { |
|
|
|
// fmt.Printf("remote: %s, filePath: %s, uploadPath: %s\n", remote, filePath, uploadPath)
|
|
|
|
// 启用日志
|
|
|
|
logger := util.NewProductionLogger() |
|
|
|
@ -173,7 +174,8 @@ func clientUploadFile(remote string, filePath string, uploadPath string) error { |
|
|
|
reader := bufio.NewReader(file) |
|
|
|
var offset int64 = 0 |
|
|
|
|
|
|
|
logger.Info("开始发送文件: %s (大小: %d bytes)", zap.String("filename", fileName), zap.String("path", filePath)) |
|
|
|
// logger.Info("开始发送文件: %s (大小: %d bytes)", zap.String("filename", fileName), zap.String("path", filePath))
|
|
|
|
fmt.Printf("开始发送文件: %s (大小: %d bytes)\n", fileName, fileInfo.Size()) |
|
|
|
|
|
|
|
// 发送文件
|
|
|
|
for { |
|
|
|
|