|
|
|
@ -21,6 +21,7 @@ type FileInfo struct { |
|
|
|
type FileChunk struct { |
|
|
|
Data []byte |
|
|
|
FileName string |
|
|
|
DirPath string |
|
|
|
Offset int64 |
|
|
|
IsLast bool |
|
|
|
} |
|
|
|
@ -61,14 +62,14 @@ func (f *UpFileService) SendFileChunk(chunk FileChunk, reply *bool) error { |
|
|
|
// 日志
|
|
|
|
logger := util.NewProductionLogger() |
|
|
|
defer logger.Sync() |
|
|
|
filePath := filepath.Join("received_files", chunk.FileName) |
|
|
|
// filePath := filepath.Join("/www/afs/logs/00", chunk.FileName)
|
|
|
|
// fmt.Printf("recive file :%s", chunk.FileName)
|
|
|
|
// 合并为实际路径
|
|
|
|
// filePath := filepath.Join(dirPath, chunk.FileName)
|
|
|
|
filePath := filepath.Join(chunk.DirPath, chunk.FileName) |
|
|
|
// filePath := chunk.FileName
|
|
|
|
|
|
|
|
// 打开文件,使用追加模式
|
|
|
|
file, err := os.OpenFile(filePath, os.O_RDWR, 0644) |
|
|
|
file, err := os.OpenFile(filePath, os.O_RDWR|os.O_CREATE, 0644) |
|
|
|
if err != nil { |
|
|
|
logger.Error("SendFileChunk OpenFile failed", zap.Error(err)) |
|
|
|
} |
|
|
|
|