diff --git a/adaptor/PCM-CORE/api/internal/handler/image/chunkimagehandler.go b/adaptor/PCM-CORE/api/internal/handler/image/chunkimagehandler.go index 60003800..0e6df523 100644 --- a/adaptor/PCM-CORE/api/internal/handler/image/chunkimagehandler.go +++ b/adaptor/PCM-CORE/api/internal/handler/image/chunkimagehandler.go @@ -25,7 +25,7 @@ func ChunkImageHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { size, _ := strconv.ParseInt(r.PostFormValue("size"), 10, 64) hash := r.PostFormValue("hash") name := r.PostFormValue("name") - + // 对比合并请求的文件大小和已上传文件夹大小 toSize, _ := getDirSize(path.Join(linuxUploadTempPath, hash)) if size != toSize { fmt.Fprintf(w, "文件上传错误") @@ -51,7 +51,7 @@ func ChunkImageHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { wg.Add(filesCount) for i := 0; i < filesCount; i++ { // 这里一定要注意按顺序读取不然文件就会损坏 - fileName := path.Join(chunksPath, "\\"+filesSort[strconv.Itoa(i)]) + fileName := path.Join(chunksPath, "/"+filesSort[strconv.Itoa(i)]) data, err := ioutil.ReadFile(fileName) fmt.Println(err) fs.Write(data) @@ -59,7 +59,7 @@ func ChunkImageHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { wg.Done() } wg.Wait() - os.RemoveAll(path.Join(chunksPath, "\\")) + os.RemoveAll(path.Join(chunksPath, "/")) defer fs.Close() //// 加载镜像文件到docker diff --git a/adaptor/PCM-CORE/api/internal/handler/image/uploadimagehandler.go b/adaptor/PCM-CORE/api/internal/handler/image/uploadimagehandler.go index 15a3e2c2..ddb36a53 100644 --- a/adaptor/PCM-CORE/api/internal/handler/image/uploadimagehandler.go +++ b/adaptor/PCM-CORE/api/internal/handler/image/uploadimagehandler.go @@ -22,7 +22,7 @@ type LoadBody struct { } var windowsUploadTempPath = strings.ReplaceAll(path.Join(windowsUploadPath, "temp"), "/", "\\") -var linuxUploadTempPath = path.Join(windowsUploadPath) +var linuxUploadTempPath = path.Join(linuxUploadPath) func UploadImageHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { return func(w http.ResponseWriter, r *http.Request) { @@ -51,7 +51,7 @@ func UploadImageHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { if !isPathExists { err = os.MkdirAll(chunksPath, os.ModePerm) } - destFile, err := os.OpenFile(path.Join(chunksPath+"\\"+hash+"-"+index), syscall.O_CREAT|syscall.O_WRONLY, 0777) + destFile, err := os.OpenFile(path.Join(chunksPath+"/"+hash+"-"+index), syscall.O_CREAT|syscall.O_WRONLY, 0777) reader := bufio.NewReader(file) writer := bufio.NewWriter(destFile) buf := make([]byte, 1024*1024) // 1M buf