| @@ -9,6 +9,7 @@ import ( | |||||
| "io/ioutil" | "io/ioutil" | ||||
| "net/http" | "net/http" | ||||
| "os" | "os" | ||||
| "path" | |||||
| "strings" | "strings" | ||||
| "code.gitea.io/gitea/models" | "code.gitea.io/gitea/models" | ||||
| @@ -661,13 +662,21 @@ func ModelConvertDownloadModel(ctx *context.Context) { | |||||
| ctx.ServerError("no file to download.", err) | ctx.ServerError("no file to download.", err) | ||||
| } | } | ||||
| } else { | } else { | ||||
| Prefix := strings.TrimPrefix(path.Join(setting.TrainJobModelPath, job.CloudBrainTaskId, "output/", "V0001", ""), "/") | |||||
| allFile, err := storage.GetAllObjectByBucketAndPrefix(setting.Bucket, Prefix) | |||||
| if err == nil { | |||||
| returnFileName := job.Name + ".zip" | |||||
| ObsDownloadManyFile(Prefix, ctx, returnFileName, allFile) | |||||
| } else { | |||||
| log.Info("error,msg=" + err.Error()) | |||||
| ctx.ServerError("no file to download.", err) | |||||
| } | |||||
| } | } | ||||
| } else { | } else { | ||||
| parentDir := ctx.Query("parentDir") | |||||
| fileName := ctx.Query("fileName") | |||||
| jobName := ctx.Query("jobName") | |||||
| if job.IsGpuTrainTask() { | if job.IsGpuTrainTask() { | ||||
| parentDir := ctx.Query("parentDir") | |||||
| fileName := ctx.Query("fileName") | |||||
| jobName := ctx.Query("jobName") | |||||
| filePath := "jobs/" + jobName + "/model/" + parentDir | filePath := "jobs/" + jobName + "/model/" + parentDir | ||||
| url, err := storage.Attachments.PresignedGetURL(filePath, fileName) | url, err := storage.Attachments.PresignedGetURL(filePath, fileName) | ||||
| if err != nil { | if err != nil { | ||||
| @@ -679,6 +688,15 @@ func ModelConvertDownloadModel(ctx *context.Context) { | |||||
| http.Redirect(ctx.Resp, ctx.Req.Request, url, http.StatusTemporaryRedirect) | http.Redirect(ctx.Resp, ctx.Req.Request, url, http.StatusTemporaryRedirect) | ||||
| } else { | } else { | ||||
| //TODO | //TODO | ||||
| ObjectKey := path.Join(setting.TrainJobModelPath, job.CloudBrainTaskId, "output/", "V0001", parentDir, fileName) | |||||
| log.Info("ObjectKey=" + ObjectKey) | |||||
| url, err := storage.GetObsCreateSignedUrlByBucketAndKey(setting.Bucket, ObjectKey) | |||||
| if err != nil { | |||||
| log.Error("GetObsCreateSignedUrl failed: %v", err.Error(), ctx.Data["msgID"]) | |||||
| ctx.ServerError("GetObsCreateSignedUrl", err) | |||||
| return | |||||
| } | |||||
| http.Redirect(ctx.Resp, ctx.Req.Request, url, http.StatusMovedPermanently) | |||||
| } | } | ||||
| } | } | ||||