diff options
author | Unknwon <u@gogs.io> | 2015-08-11 23:24:40 +0800 |
---|---|---|
committer | Unknwon <u@gogs.io> | 2015-08-11 23:24:40 +0800 |
commit | 34f6cbfc2a13295d2c8ab33f17ddbca27337b18b (patch) | |
tree | 1264ba8fa4370d05c0f5efcd81d7e28380110454 /cmd | |
parent | 89c2bd4a0dd85261f72565ba8395644da8129fea (diff) | |
download | gitea-34f6cbfc2a13295d2c8ab33f17ddbca27337b18b.tar.gz gitea-34f6cbfc2a13295d2c8ab33f17ddbca27337b18b.zip |
finish attachments when create issue
Diffstat (limited to 'cmd')
-rw-r--r-- | cmd/web.go | 18 |
1 files changed, 16 insertions, 2 deletions
diff --git a/cmd/web.go b/cmd/web.go index 445031ffaf..decad7d34f 100644 --- a/cmd/web.go +++ b/cmd/web.go @@ -327,7 +327,22 @@ func runWeb(ctx *cli.Context) { m.Group("", func() { m.Get("/:username", user.Profile) - m.Post("/attachments", repo.UploadAttachment) + m.Get("/attachments/:uuid", func(ctx *middleware.Context) { + attach, err := models.GetAttachmentByUUID(ctx.Params(":uuid")) + if err != nil { + if models.IsErrAttachmentNotExist(err) { + ctx.Error(404) + } else { + ctx.Handle(500, "GetAttachmentByUUID", err) + } + return + } + + // Fix #312. Attachments with , in their name are not handled correctly by Google Chrome. + // We must put the name in " manually. + ctx.ServeFileContent(attach.LocalPath(), "\""+attach.Name+"\"") + }) + m.Post("/issues/attachments", repo.UploadIssueAttachment) }, ignSignIn) if macaron.Env == macaron.DEV { @@ -428,7 +443,6 @@ func runWeb(ctx *cli.Context) { m.Post("/:index/label", repo.UpdateIssueLabel) m.Post("/:index/milestone", repo.UpdateIssueMilestone) m.Post("/:index/assignee", repo.UpdateAssignee) - m.Get("/:index/attachment/:id", repo.IssueGetAttachment) }) m.Group("/labels", func() { m.Post("/new", bindIgnErr(auth.CreateLabelForm{}), repo.NewLabel) |