summaryrefslogtreecommitdiffstats
path: root/services
diff options
context:
space:
mode:
authorKN4CK3R <admin@oldschoolhack.me>2024-03-02 18:02:01 +0100
committerEarl Warren <contact@earl-warren.org>2024-03-06 05:10:46 +0100
commit47a913d40d3417858f2ee51a7dbed64ca84eff60 (patch)
tree237ee21ee7b21dfeb7ff8bd49ae2bcd9a82e724e /services
parentFix queue worker incorrectly stopped when there are still more items in the q... (diff)
downloadforgejo-47a913d40d3417858f2ee51a7dbed64ca84eff60.tar.xz
forgejo-47a913d40d3417858f2ee51a7dbed64ca84eff60.zip
Add support for API blob upload of release attachments (#29507)
Fixes #29502 Our endpoint is not Github compatible. https://docs.github.com/en/rest/releases/assets?apiVersion=2022-11-28#upload-a-release-asset --------- Co-authored-by: Giteabot <teabot@gitea.io> (cherry picked from commit 70c126e6184872a6ac63cae2f327fc745b25d1d7)
Diffstat (limited to 'services')
-rw-r--r--services/attachment/attachment.go6
1 files changed, 3 insertions, 3 deletions
diff --git a/services/attachment/attachment.go b/services/attachment/attachment.go
index 4d4fdd4f83..4481966b4a 100644
--- a/services/attachment/attachment.go
+++ b/services/attachment/attachment.go
@@ -44,14 +44,14 @@ func NewAttachment(ctx context.Context, attach *repo_model.Attachment, file io.R
}
// UploadAttachment upload new attachment into storage and update database
-func UploadAttachment(ctx context.Context, file io.Reader, allowedTypes string, fileSize int64, opts *repo_model.Attachment) (*repo_model.Attachment, error) {
+func UploadAttachment(ctx context.Context, file io.Reader, allowedTypes string, fileSize int64, attach *repo_model.Attachment) (*repo_model.Attachment, error) {
buf := make([]byte, 1024)
n, _ := util.ReadAtMost(file, buf)
buf = buf[:n]
- if err := upload.Verify(buf, opts.Name, allowedTypes); err != nil {
+ if err := upload.Verify(buf, attach.Name, allowedTypes); err != nil {
return nil, err
}
- return NewAttachment(ctx, opts, io.MultiReader(bytes.NewReader(buf), file), fileSize)
+ return NewAttachment(ctx, attach, io.MultiReader(bytes.NewReader(buf), file), fileSize)
}