From 1542a01924ca9e8d3752b407775fed2fb0bd1500 Mon Sep 17 00:00:00 2001 From: Evgeniy Kulikov Date: Tue, 4 Feb 2020 14:02:29 +0300 Subject: [PATCH] Use path.Base because hdr.Value can be something like `/path/to/filename.ext` --- receive.go | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/receive.go b/receive.go index 319c7ea..78c79c1 100644 --- a/receive.go +++ b/receive.go @@ -4,6 +4,7 @@ import ( "context" "io" "net/http" + "path" "strconv" "strings" @@ -98,7 +99,8 @@ func (r *router) receiveFile(c echo.Context) error { c.Response().Header().Set("x-"+hdr.Key, hdr.Value) if hdr.Key == object.FilenameHeader && download { - c.Response().Header().Set("Content-Disposition", "attachment; filename="+hdr.Value) + // NOTE: we use path.Base because hdr.Value can be something like `/path/to/filename.ext` + c.Response().Header().Set("Content-Disposition", "attachment; filename="+path.Base(hdr.Value)) } } }