| @@ -128,37 +128,37 @@ func GetAttachment(ctx *context.Context) { | |||||
| } | } | ||||
| //If we have matched and access to release or issue | //If we have matched and access to release or issue | ||||
| /* | |||||
| fr, err := storage.Attachments.Open(attach.RelativePath()) | |||||
| if err != nil { | |||||
| ctx.ServerError("Open", err) | |||||
| return | |||||
| } | |||||
| defer fr.Close() | |||||
| if setting.Attachment.StoreType == "minio" { | |||||
| url, err := storage.Attachments.PresignedGetURL(attach.RelativePath(), attach.Name) | |||||
| if err != nil { | |||||
| ctx.ServerError("PresignedGetURL", err) | |||||
| return | |||||
| } | |||||
| */ | |||||
| if err := attach.IncreaseDownloadCount(); err != nil { | |||||
| ctx.ServerError("Update", err) | |||||
| return | |||||
| } | |||||
| url, err := storage.Attachments.PresignedGetURL(attach.RelativePath(), attach.Name) | |||||
| if err != nil { | |||||
| ctx.ServerError("PresignedGetURL", err) | |||||
| return | |||||
| } | |||||
| http.Redirect(ctx.Resp, ctx.Req.Request, url, http.StatusMovedPermanently) | |||||
| if err := attach.IncreaseDownloadCount(); err != nil { | |||||
| ctx.ServerError("Update", err) | |||||
| return | |||||
| } | |||||
| } else { | |||||
| fr, err := storage.Attachments.Open(attach.RelativePath()) | |||||
| if err != nil { | |||||
| ctx.ServerError("Open", err) | |||||
| return | |||||
| } | |||||
| defer fr.Close() | |||||
| ctx.JSON(200, map[string]string{ | |||||
| "name": attach.Name, | |||||
| "url": url, | |||||
| }) | |||||
| if err := attach.IncreaseDownloadCount(); err != nil { | |||||
| ctx.ServerError("Update", err) | |||||
| return | |||||
| } | |||||
| /* | |||||
| if err = ServeData(ctx, attach.Name, fr); err != nil { | |||||
| ctx.ServerError("ServeData", err) | |||||
| return | |||||
| if err = ServeData(ctx, attach.Name, fr); err != nil { | |||||
| ctx.ServerError("ServeData", err) | |||||
| return | |||||
| } | |||||
| } | } | ||||
| */ | |||||
| } | } | ||||