forked from forgejo/forgejo
fix upload attachments (#6481)
* fix upload attachments * add migration for new column uploader_id on table attachment * fix imports sequence
This commit is contained in:
parent
0a8e63c682
commit
09fb036ad6
7 changed files with 76 additions and 14 deletions
|
@ -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())
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue