|
|
@@ -5,6 +5,7 @@ |
|
|
|
package repo |
|
|
|
|
|
|
|
import ( |
|
|
|
"code.gitea.io/gitea/modules/storage" |
|
|
|
"fmt" |
|
|
|
"net/http" |
|
|
|
"strings" |
|
|
@@ -13,7 +14,6 @@ import ( |
|
|
|
"code.gitea.io/gitea/modules/context" |
|
|
|
"code.gitea.io/gitea/modules/log" |
|
|
|
"code.gitea.io/gitea/modules/setting" |
|
|
|
"code.gitea.io/gitea/modules/storage" |
|
|
|
"code.gitea.io/gitea/modules/upload" |
|
|
|
) |
|
|
|
|
|
|
@@ -124,6 +124,7 @@ 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) |
|
|
@@ -131,13 +132,29 @@ func GetAttachment(ctx *context.Context) { |
|
|
|
} |
|
|
|
defer fr.Close() |
|
|
|
|
|
|
|
*/ |
|
|
|
|
|
|
|
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 |
|
|
|
} |
|
|
|
|
|
|
|
ctx.JSON(200, map[string]string{ |
|
|
|
"name": attach.Name, |
|
|
|
"url": url, |
|
|
|
}) |
|
|
|
|
|
|
|
/* |
|
|
|
if err = ServeData(ctx, attach.Name, fr); err != nil { |
|
|
|
ctx.ServerError("ServeData", err) |
|
|
|
return |
|
|
|
} |
|
|
|
|
|
|
|
*/ |
|
|
|
} |