From 9c6fbfc16f4e1b74409df1ba3d1b27b18c85f6dd Mon Sep 17 00:00:00 2001 From: NodudeWasTaken <75137537+NodudeWasTaken@users.noreply.github.com> Date: Tue, 27 Feb 2024 06:11:40 +0100 Subject: [PATCH] Add filename to image serve (#4616) --- pkg/models/model_file.go | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/pkg/models/model_file.go b/pkg/models/model_file.go index 0ff90d1af..d32368508 100644 --- a/pkg/models/model_file.go +++ b/pkg/models/model_file.go @@ -199,6 +199,12 @@ func (f *BaseFile) Serve(fs FS, w http.ResponseWriter, r *http.Request) error { } else { 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) return nil