1
0
mirror of https://github.com/labstack/echo.git synced 2025-02-15 13:53:06 +02:00
Signed-off-by: Vishal Rana <vr@labstack.com>
This commit is contained in:
Vishal Rana 2017-03-15 11:38:43 -07:00
parent 42e83ed0b9
commit 477d8dc708

View File

@ -471,7 +471,12 @@ func (c *context) Stream(code int, contentType string, r io.Reader) (err error)
return
}
func (c *context) File(file string) error {
func (c *context) File(file string) (err error) {
file, err = url.QueryUnescape(file) // Issue #839
if err != nil {
return
}
f, err := os.Open(file)
if err != nil {
return ErrNotFound
@ -487,11 +492,11 @@ func (c *context) File(file string) error {
}
defer f.Close()
if fi, err = f.Stat(); err != nil {
return err
return
}
}
http.ServeContent(c.Response(), c.Request(), fi.Name(), fi.ModTime(), f)
return nil
return
}
func (c *context) Attachment(file, name string) (err error) {