Merge pull request #728 from wunter8/attachment-filename

set attachment filename when download through browser
This commit is contained in:
Philipp C. Heckel 2023-05-14 14:15:31 -04:00 committed by GitHub
commit 8f87e9008b
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 4 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
}