Browse Source

GetAttachment:301 redirect to minio

tags/v1.21.12.1
e 5 years ago
parent
commit
076fdb0b8d
1 changed files with 26 additions and 26 deletions
  1. +26
    -26
      routers/repo/attachment.go

+ 26
- 26
routers/repo/attachment.go View File

@@ -128,37 +128,37 @@ func GetAttachment(ctx *context.Context) {
}

//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
}
}

*/
}

Loading…
Cancel
Save