| @@ -459,42 +459,55 @@ func DownloadSingleModelFile(ctx *context.Context) { | |||
| ctx.NotFound(ctx.Req.URL.RequestURI(), nil) | |||
| return | |||
| } | |||
| if setting.PROXYURL != "" { | |||
| body, err := storage.ObsDownloadAFile(setting.Bucket, path) | |||
| if err != nil { | |||
| log.Info("download error.") | |||
| if task.Type == models.TypeCloudBrainTwo { | |||
| if setting.PROXYURL != "" { | |||
| body, err := storage.ObsDownloadAFile(setting.Bucket, path) | |||
| if err != nil { | |||
| log.Info("download error.") | |||
| } else { | |||
| //count++ | |||
| models.ModifyModelDownloadCount(id) | |||
| defer body.Close() | |||
| ctx.Resp.Header().Set("Content-Disposition", "attachment; filename="+fileName) | |||
| ctx.Resp.Header().Set("Content-Type", "application/octet-stream") | |||
| p := make([]byte, 1024) | |||
| var readErr error | |||
| var readCount int | |||
| // 读取对象内容 | |||
| for { | |||
| readCount, readErr = body.Read(p) | |||
| if readCount > 0 { | |||
| ctx.Resp.Write(p[:readCount]) | |||
| //fmt.Printf("%s", p[:readCount]) | |||
| } | |||
| if readErr != nil { | |||
| break | |||
| } | |||
| } | |||
| } | |||
| } else { | |||
| url, err := storage.GetObsCreateSignedUrlByBucketAndKey(setting.Bucket, path) | |||
| if err != nil { | |||
| log.Error("GetObsCreateSignedUrl failed: %v", err.Error(), ctx.Data["msgID"]) | |||
| ctx.ServerError("GetObsCreateSignedUrl", err) | |||
| return | |||
| } | |||
| //count++ | |||
| models.ModifyModelDownloadCount(id) | |||
| defer body.Close() | |||
| ctx.Resp.Header().Set("Content-Disposition", "attachment; filename="+fileName) | |||
| ctx.Resp.Header().Set("Content-Type", "application/octet-stream") | |||
| p := make([]byte, 1024) | |||
| var readErr error | |||
| var readCount int | |||
| // 读取对象内容 | |||
| for { | |||
| readCount, readErr = body.Read(p) | |||
| if readCount > 0 { | |||
| ctx.Resp.Write(p[:readCount]) | |||
| //fmt.Printf("%s", p[:readCount]) | |||
| } | |||
| if readErr != nil { | |||
| break | |||
| } | |||
| } | |||
| http.Redirect(ctx.Resp, ctx.Req.Request, url, http.StatusMovedPermanently) | |||
| } | |||
| } else { | |||
| url, err := storage.GetObsCreateSignedUrlByBucketAndKey(setting.Bucket, path) | |||
| } else if task.Type == models.TypeCloudBrainOne { | |||
| log.Info("start to down load minio file.") | |||
| url, err := storage.Attachments.PresignedGetURL(path, fileName) | |||
| if err != nil { | |||
| log.Error("GetObsCreateSignedUrl failed: %v", err.Error(), ctx.Data["msgID"]) | |||
| ctx.ServerError("GetObsCreateSignedUrl", err) | |||
| log.Error("Get minio get SignedUrl failed: %v", err.Error(), ctx.Data["msgID"]) | |||
| ctx.ServerError("Get minio get SignedUrl failed", err) | |||
| return | |||
| } | |||
| //count++ | |||
| models.ModifyModelDownloadCount(id) | |||
| http.Redirect(ctx.Resp, ctx.Req.Request, url, http.StatusMovedPermanently) | |||
| } | |||
| } | |||
| func ShowModelInfo(ctx *context.Context) { | |||