From 4fa06554382b32365a10dd1bb07f7cfa3d83ba6c Mon Sep 17 00:00:00 2001 From: Hunter Kehoe Date: Sun, 14 May 2023 11:19:49 -0600 Subject: [PATCH] set attachment filename when download through browser --- server/server.go | 3 +++ 1 file changed, 3 insertions(+) diff --git a/server/server.go b/server/server.go index c0ebc6eb..05b77d57 100644 --- a/server/server.go +++ b/server/server.go @@ -642,6 +642,9 @@ func (s *Server) handleFile(w http.ResponseWriter, r *http.Request, v *visitor) return err } 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) return err }