set attachment filename when download through browser

pull/728/head
Hunter Kehoe 2023-05-14 11:19:49 -06:00
parent bd81aef1c9
commit 4fa0655438
1 changed files with 3 additions and 0 deletions

View File

@ -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
}