fix file attachment function to make sure all browser will get the same filename

This commit is contained in:
hiimyusheng 2022-03-02 12:06:34 +08:00
parent 3757142584
commit 4174c907f2

View File

@ -1018,7 +1018,7 @@ func (c *Context) FileFromFS(filepath string, fs http.FileSystem) {
// FileAttachment writes the specified file into the body stream in an efficient way
// On the client side, the file will typically be downloaded with the given filename
func (c *Context) FileAttachment(filepath, filename string) {
c.Writer.Header().Set("Content-Disposition", fmt.Sprintf("attachment; filename=\"%s\"", filename))
c.Writer.Header().Set("Content-Disposition", fmt.Sprintf("attachment; filename=%s", filename))
http.ServeFile(c.Writer, c.Request, filepath)
}