From 66241b81c21423c5a35eaadf393e1ad8fb53eb1e Mon Sep 17 00:00:00 2001 From: Henrique Dias Date: Thu, 29 Dec 2016 19:44:08 +0000 Subject: [PATCH] fix bug, download on root Former-commit-id: 72e65e85fb2cee6d118b63e136912997ebfc8e79 --- handlers/download.go | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/handlers/download.go b/handlers/download.go index 4b064499..9c5b61c9 100644 --- a/handlers/download.go +++ b/handlers/download.go @@ -77,7 +77,12 @@ func Download(w http.ResponseWriter, r *http.Request, c *config.Config, i *file. return http.StatusInternalServerError, err } - w.Header().Set("Content-Disposition", "attachment; filename="+i.Name()+extension) + name := i.Name() + if name == "" { + name = "download" + } + + w.Header().Set("Content-Disposition", "attachment; filename="+name+extension) io.Copy(w, file) return http.StatusOK, nil }