From 095ccb44e45c500973e80970f7b7c91c8af5fc14 Mon Sep 17 00:00:00 2001 From: zhangwei <894646498@qq.com> Date: Wed, 24 May 2023 16:46:06 +0800 Subject: [PATCH] =?UTF-8?q?windows=E5=92=8Clinux=E8=B7=AF=E5=BE=84?= =?UTF-8?q?=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Former-commit-id: 54e5eee24cfe089fb275883bb48a775daa1554ac --- .../api/internal/handler/image/chunkimagehandler.go | 6 +++--- .../api/internal/handler/image/uploadimagehandler.go | 4 ++-- 2 files changed, 5 insertions(+), 5 deletions(-) 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