Add filename to image serve (#4616)

This commit is contained in:
NodudeWasTaken 2024-02-27 06:11:40 +01:00 committed by GitHub
parent 6a9175c954
commit 9c6fbfc16f
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 6 additions and 0 deletions

View File

@ -199,6 +199,12 @@ func (f *BaseFile) Serve(fs FS, w http.ResponseWriter, r *http.Request) error {
} else { } else {
w.Header().Set("Cache-Control", "no-cache") w.Header().Set("Cache-Control", "no-cache")
} }
// Set filename if not previously set
if w.Header().Get("Content-Disposition") == "" {
w.Header().Set("Content-Disposition", fmt.Sprintf("filename=%s", f.Basename))
}
http.ServeContent(w, r, f.Basename, f.ModTime, content) http.ServeContent(w, r, f.Basename, f.ModTime, content)
return nil return nil