From f2d195113dfe4eafe1f75046eb5aebb3c2fcdbd7 Mon Sep 17 00:00:00 2001 From: zouap Date: Tue, 15 Nov 2022 14:22:25 +0800 Subject: [PATCH 1/2] =?UTF-8?q?=E6=8F=90=E4=BA=A4=E4=BB=A3=E7=A0=81?= =?UTF-8?q?=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: zouap --- routers/repo/attachment_model.go | 82 -------------------------------- 1 file changed, 82 deletions(-) diff --git a/routers/repo/attachment_model.go b/routers/repo/attachment_model.go index b5b21b06b..bfd298744 100644 --- a/routers/repo/attachment_model.go +++ b/routers/repo/attachment_model.go @@ -135,90 +135,8 @@ func GetModelChunks(ctx *context.Context) { }) } } - - // //使用description存储模型信息 - // dbmodeluuid := attach.Description - // modelname := "" - // if dbmodeluuid != modeluuid { - // log.Info("The file has uploaded.fileChunk.ObjectName=" + fileChunk.ObjectName + " typeCloudBrain=" + fmt.Sprint(typeCloudBrain)) - // isExist := copyModelAttachmentFile(typeCloudBrain, fileChunk, fileName, modeluuid) - // if isExist { - // model, err := models.QueryModelById(modeluuid) - // if err == nil && model != nil { - // modelname = model.Name - // } - // ctx.JSON(200, map[string]string{ - // "uuid": fileChunk.UUID, - // "uploaded": strconv.Itoa(fileChunk.IsUploaded), - // "uploadID": fileChunk.UploadID, - // "chunks": string(chunks), - // "attachID": strconv.Itoa(int(attachID)), - // "modeluuid": modeluuid, - // "fileName": attach.Name, - // "modelName": modelname, - // }) - // } else { - // UpdateModelSize(modeluuid) - // ctx.JSON(200, map[string]string{ - // "uuid": fileChunk.UUID, - // "uploaded": strconv.Itoa(fileChunk.IsUploaded), - // "uploadID": fileChunk.UploadID, - // "chunks": string(chunks), - // "attachID": strconv.Itoa(int(attachID)), - // "fileName": attach.Name, - // }) - // } - // return - // } else { - // model, err := models.QueryModelById(dbmodeluuid) - // if err == nil { - // modelname = model.Name - // } - // ctx.JSON(200, map[string]string{ - // "uuid": fileChunk.UUID, - // "uploaded": strconv.Itoa(fileChunk.IsUploaded), - // "uploadID": fileChunk.UploadID, - // "chunks": string(chunks), - // "attachID": strconv.Itoa(int(attachID)), - // "modeluuid": dbmodeluuid, - // "fileName": attach.Name, - // "modelName": modelname, - // }) - // return - // } - } -// func copyModelAttachmentFile(typeCloudBrain int, fileChunk *models.ModelFileChunk, fileName, modeluuid string) bool { -// srcObjectName := fileChunk.ObjectName -// var isExist bool -// //copy -// destObjectName := getObjectName(fileName, modeluuid) -// if typeCloudBrain == models.TypeCloudBrainOne { -// bucketName := setting.Attachment.Minio.Bucket -// log.Info("minio copy..srcObjectName=" + srcObjectName + " bucketName=" + bucketName) -// if storage.MinioGetFilesSize(bucketName, []string{destObjectName}) > 0 { -// isExist = true -// } else { - -// log.Info("minio copy..srcObjectName=" + srcObjectName + " bucketName=" + bucketName) -// storage.MinioCopyAFile(bucketName, srcObjectName, bucketName, destObjectName) -// } -// } else { -// bucketName := setting.Bucket -// log.Info("obs copy..srcObjectName=" + srcObjectName + " bucketName=" + bucketName + " destObjectName=" + destObjectName) -// size := storage.ObsGetFilesSize(bucketName, []string{destObjectName}) -// log.Info("size=" + fmt.Sprint(size)) -// if size > 0 { -// isExist = true -// } else { -// log.Info("obs copy..srcObjectName=" + srcObjectName + " bucketName=" + bucketName) -// storage.ObsCopyFile(bucketName, srcObjectName, bucketName, destObjectName) -// } -// } -// return isExist -// } - func getObjectName(filename string, modeluuid string) string { return strings.TrimPrefix(path.Join(Model_prefix, path.Join(modeluuid[0:1], modeluuid[1:2], modeluuid, filename)), "/") } From 218c06fcf530af56e17c48b87a7148ef44f563e9 Mon Sep 17 00:00:00 2001 From: zouap Date: Tue, 15 Nov 2022 14:33:23 +0800 Subject: [PATCH 2/2] =?UTF-8?q?=E6=8F=90=E4=BA=A4=E4=BB=A3=E7=A0=81?= =?UTF-8?q?=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: zouap --- routers/repo/attachment_model.go | 18 ++++++------------ 1 file changed, 6 insertions(+), 12 deletions(-) diff --git a/routers/repo/attachment_model.go b/routers/repo/attachment_model.go index bfd298744..efc7cbe08 100644 --- a/routers/repo/attachment_model.go +++ b/routers/repo/attachment_model.go @@ -227,7 +227,6 @@ func GetModelMultipartUploadUrl(ctx *context.Context) { uploadID := ctx.Query("uploadID") partNumber := ctx.QueryInt("chunkNumber") size := ctx.QueryInt64("size") - fileName := ctx.Query("file_name") typeCloudBrain := ctx.QueryInt("type") err := checkTypeCloudBrain(typeCloudBrain) if err != nil { @@ -249,24 +248,19 @@ func GetModelMultipartUploadUrl(ctx *context.Context) { ctx.Error(400, fmt.Sprintf("chunk size(%d) is too big", size)) return } - url, err = storage.GenMultiPartSignedUrl(fileChunk.ObjectName, uploadID, partNumber, size) if err != nil { ctx.Error(500, fmt.Sprintf("GenMultiPartSignedUrl failed: %v", err)) return } } else { - if setting.PROXYURL != "" { - url = setting.PROXYURL + "/obs_proxy_multipart?uuid=" + uuid + "&uploadId=" + uploadID + "&partNumber=" + fmt.Sprint(partNumber) + "&file_name=" + fileName - log.Info("return url=" + url) - } else { - url, err = storage.ObsGenMultiPartSignedUrl(fileChunk.ObjectName, uploadID, partNumber) - if err != nil { - ctx.Error(500, fmt.Sprintf("ObsGenMultiPartSignedUrl failed: %v", err)) - return - } - log.Info("url=" + url) + url, err = storage.ObsGenMultiPartSignedUrl(fileChunk.ObjectName, uploadID, partNumber) + if err != nil { + ctx.Error(500, fmt.Sprintf("ObsGenMultiPartSignedUrl failed: %v", err)) + return } + log.Info("url=" + url) + } ctx.JSON(200, map[string]string{