|
|
@@ -143,6 +143,13 @@ func DeleteAttachment(ctx *context.Context) { |
|
|
|
|
|
|
|
// GetAttachment serve attachements |
|
|
|
func GetAttachment(ctx *context.Context) { |
|
|
|
typeCloudBrain := ctx.QueryInt("type") |
|
|
|
err := checkTypeCloudBrain(typeCloudBrain) |
|
|
|
if err != nil { |
|
|
|
ctx.ServerError("checkTypeCloudBrain failed", err) |
|
|
|
return |
|
|
|
} |
|
|
|
|
|
|
|
attach, err := models.GetAttachmentByUUID(ctx.Params(":uuid")) |
|
|
|
if err != nil { |
|
|
|
if models.IsErrAttachmentNotExist(err) { |
|
|
@@ -196,19 +203,29 @@ func GetAttachment(ctx *context.Context) { |
|
|
|
|
|
|
|
//If we have matched and access to release or issue |
|
|
|
if setting.Attachment.StoreType == storage.MinioStorageType { |
|
|
|
url, err := storage.Attachments.PresignedGetURL(attach.RelativePath(), attach.Name) |
|
|
|
if err != nil { |
|
|
|
ctx.ServerError("PresignedGetURL", err) |
|
|
|
return |
|
|
|
url := "" |
|
|
|
if typeCloudBrain == models.TypeCloudBrainOne { |
|
|
|
url, err = storage.Attachments.PresignedGetURL(attach.RelativePath(), attach.Name) |
|
|
|
if err != nil { |
|
|
|
ctx.ServerError("PresignedGetURL", err) |
|
|
|
return |
|
|
|
} |
|
|
|
} else { |
|
|
|
url, err = storage.ObsGetPreSignedUrl(attach.UUID, attach.Name) |
|
|
|
if err != nil { |
|
|
|
ctx.ServerError("ObsGetPreSignedUrl", err) |
|
|
|
return |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
log.Info(url) |
|
|
|
|
|
|
|
if err = increaseDownloadCount(attach, dataSet); err != nil { |
|
|
|
ctx.ServerError("Update", err) |
|
|
|
return |
|
|
|
} |
|
|
|
|
|
|
|
http.Redirect(ctx.Resp, ctx.Req.Request, url, http.StatusMovedPermanently) |
|
|
|
|
|
|
|
} else { |
|
|
|
fr, err := storage.Attachments.Open(attach.RelativePath()) |
|
|
|
if err != nil { |
|
|
|