|
|
@@ -551,6 +551,7 @@ func GetSuccessChunks(ctx *context.Context) { |
|
|
|
typeCloudBrain := ctx.QueryInt("type") |
|
|
|
fileName := ctx.Query("file_name") |
|
|
|
scene := ctx.Query("scene") |
|
|
|
modeluuid := ctx.Query("modeluuid") |
|
|
|
log.Info("scene=" + scene) |
|
|
|
var chunks string |
|
|
|
|
|
|
@@ -664,24 +665,50 @@ func GetSuccessChunks(ctx *context.Context) { |
|
|
|
} |
|
|
|
if scene == Attachment_model { |
|
|
|
//使用description存储模型信息 |
|
|
|
modeluuid := attach.Description |
|
|
|
dbmodeluuid := attach.Description |
|
|
|
modelname := "" |
|
|
|
if modeluuid != "" { |
|
|
|
model, err := models.QueryModelById(modeluuid) |
|
|
|
if dbmodeluuid != modeluuid { |
|
|
|
model, err := models.QueryModelById(dbmodeluuid) |
|
|
|
if err == nil { |
|
|
|
modelname = model.Name |
|
|
|
} |
|
|
|
//copy |
|
|
|
srcObjectName := fileChunk.ObjectName |
|
|
|
destObjectName := getObjectName(fileName, modeluuid) |
|
|
|
if typeCloudBrain == models.TypeCloudBrainOne { |
|
|
|
bucketName := setting.Attachment.Minio.Bucket |
|
|
|
storage.MinioCopyAFile(bucketName, srcObjectName, bucketName, destObjectName) |
|
|
|
} else { |
|
|
|
bucketName := setting.Bucket |
|
|
|
storage.ObsCopyFile(bucketName, srcObjectName, bucketName, destObjectName) |
|
|
|
} |
|
|
|
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 |
|
|
|
} |
|
|
|
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 { |
|
|
|
dataset, err := models.GetDatasetByID(attach.DatasetID) |
|
|
|
if err != nil { |
|
|
@@ -702,6 +729,10 @@ func GetSuccessChunks(ctx *context.Context) { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
func getObjectName(filename string, modeluuid string) string { |
|
|
|
return strings.TrimPrefix(path.Join(Model_prefix, path.Join(modeluuid[0:1], modeluuid[1:2], modeluuid, filename)), "/") |
|
|
|
} |
|
|
|
|
|
|
|
func getMinioInitObjectName(scene string, uuid, modeluuid string, filename string) string { |
|
|
|
if scene == Attachment_model { |
|
|
|
return strings.TrimPrefix(path.Join(Model_prefix, path.Join(modeluuid[0:1], modeluuid[1:2], modeluuid, filename)), "/") |
|
|
|