set attachment filename when download through browser
This commit is contained in:
@@ -642,6 +642,9 @@ func (s *Server) handleFile(w http.ResponseWriter, r *http.Request, v *visitor)
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
defer f.Close()
|
defer f.Close()
|
||||||
|
if m.Attachment.Name != "" {
|
||||||
|
w.Header().Set("Content-Disposition", "attachment; filename="+strconv.Quote(m.Attachment.Name))
|
||||||
|
}
|
||||||
_, err = io.Copy(util.NewContentTypeWriter(w, r.URL.Path), f)
|
_, err = io.Copy(util.NewContentTypeWriter(w, r.URL.Path), f)
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user