From 34f6cbfc2a13295d2c8ab33f17ddbca27337b18b Mon Sep 17 00:00:00 2001 From: Unknwon Date: Tue, 11 Aug 2015 23:24:40 +0800 Subject: finish attachments when create issue --- cmd/web.go | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) (limited to 'cmd') diff --git a/cmd/web.go b/cmd/web.go index 445031ff..decad7d3 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) -- cgit v1.2.3