|
|
|
@ -44,7 +44,7 @@ type ZipBlock struct { |
|
|
|
|
|
|
|
// 处理文件上传
|
|
|
|
// dirpath 目标文件存放位置
|
|
|
|
func (f *FileService) Upload(stream pb.FileUploadService_UploadFileServer, dirpath string) error { |
|
|
|
func (f *FileService) UploadFile(stream pb.FileUploadService_UploadFileServer, dirpath string) error { |
|
|
|
var ( |
|
|
|
file *os.File |
|
|
|
fileInfo *pb.FileInfo |
|
|
|
@ -176,11 +176,11 @@ func clientUploadFile(remote string, filePath string, uploadPath string) error { |
|
|
|
defer conn.Close() |
|
|
|
client := pb.NewFileUploadServiceClient(conn) |
|
|
|
// 调用RPC方法
|
|
|
|
stream, err := client.UploadFile(context.Background()) |
|
|
|
if err != nil { |
|
|
|
logger.Error("clientUploadFile", zap.String("msg", "无法创建上传流"), zap.Error(err)) |
|
|
|
return err |
|
|
|
} |
|
|
|
// stream, err := client.UploadFile(context.Background())
|
|
|
|
// if err != nil {
|
|
|
|
// logger.Error("clientUploadFile", zap.String("msg", "无法创建上传流"), zap.Error(err))
|
|
|
|
// return err
|
|
|
|
// }
|
|
|
|
|
|
|
|
// 打开文件
|
|
|
|
file, err := os.Open(filePath) |
|
|
|
@ -209,7 +209,8 @@ func clientUploadFile(remote string, filePath string, uploadPath string) error { |
|
|
|
fileInfo.Name(), fileInfo.Size(), totalChunks) |
|
|
|
|
|
|
|
// 创建流式上传
|
|
|
|
stream, err = client.UploadFile(context.Background()) |
|
|
|
// eg 函数为 远程的调用函数
|
|
|
|
stream, err := client.UploadFile(context.Background(), uploadPath) |
|
|
|
if err != nil { |
|
|
|
logger.Error("clientUploadFile", zap.String("msg", "无法创建上传流"), zap.Error(err)) |
|
|
|
return err |
|
|
|
|