summaryrefslogtreecommitdiffstats
path: root/routers/api
diff options
context:
space:
mode:
authorLunny Xiao <xiaolunwen@gmail.com>2019-04-03 03:25:05 +0800
committertechknowlogick <matti@mdranta.net>2019-04-02 15:25:05 -0400
commit09fb036ad625ec5178319c30df47aac313fdbbe3 (patch)
tree4e5389c39924532023041d530b02a94d3bf987d2 /routers/api
parent0a8e63c68292a08d8a7bc4fa397ae41235f086a7 (diff)
downloadgitea-09fb036ad625ec5178319c30df47aac313fdbbe3.tar.gz
gitea-09fb036ad625ec5178319c30df47aac313fdbbe3.zip
fix upload attachments (#6481)
* fix upload attachments * add migration for new column uploader_id on table attachment * fix imports sequence
Diffstat (limited to 'routers/api')
-rw-r--r--routers/api/v1/repo/release_attachment.go12
1 files changed, 6 insertions, 6 deletions
diff --git a/routers/api/v1/repo/release_attachment.go b/routers/api/v1/repo/release_attachment.go
index 50107dd44e..5efdd69817 100644
--- a/routers/api/v1/repo/release_attachment.go
+++ b/routers/api/v1/repo/release_attachment.go
@@ -200,16 +200,16 @@ func CreateReleaseAttachment(ctx *context.APIContext) {
}
// Create a new attachment and save the file
- attach, err := models.NewAttachment(filename, buf, file)
+ attach, err := models.NewAttachment(&models.Attachment{
+ UploaderID: ctx.User.ID,
+ Name: filename,
+ ReleaseID: release.ID,
+ }, buf, file)
if err != nil {
ctx.Error(500, "NewAttachment", err)
return
}
- attach.ReleaseID = release.ID
- if err := models.UpdateAttachment(attach); err != nil {
- ctx.Error(500, "UpdateAttachment", err)
- return
- }
+
ctx.JSON(201, attach.APIFormat())
}