From 2ed9e5332d7bfeb08877e38af5bd633ba0fd3a37 Mon Sep 17 00:00:00 2001 From: fancydancers <235832478+fancydancers@users.noreply.github.com> Date: Thu, 9 Oct 2025 02:35:11 +0000 Subject: [PATCH] add content-disposition filename header to streams (#6119) * add content-disposition filename header to streams * Fix filename generation on windows --------- Co-authored-by: WithoutPants <53250216+WithoutPants@users.noreply.github.com> --- internal/manager/running_streams.go | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/internal/manager/running_streams.go b/internal/manager/running_streams.go index c6b0c4665..18ac3b042 100644 --- a/internal/manager/running_streams.go +++ b/internal/manager/running_streams.go @@ -3,7 +3,9 @@ package manager import ( "context" "errors" + "mime" "net/http" + "path/filepath" "github.com/stashapp/stash/internal/manager/config" "github.com/stashapp/stash/internal/static" @@ -46,14 +48,17 @@ func (s *SceneServer) StreamSceneDirect(scene *models.Scene, w http.ResponseWrit sceneHash := scene.GetHash(config.GetInstance().GetVideoFileNamingAlgorithm()) - filepath := GetInstance().Paths.Scene.GetStreamPath(scene.Path, sceneHash) + fp := GetInstance().Paths.Scene.GetStreamPath(scene.Path, sceneHash) streamRequestCtx := ffmpeg.NewStreamRequestContext(w, r) // #2579 - hijacking and closing the connection here causes video playback to fail in Safari // We trust that the request context will be closed, so we don't need to call Cancel on the // returned context here. - _ = GetInstance().ReadLockManager.ReadLock(streamRequestCtx, filepath) - http.ServeFile(w, r, filepath) + _ = GetInstance().ReadLockManager.ReadLock(streamRequestCtx, fp) + _, filename := filepath.Split(fp) + contentDisposition := mime.FormatMediaType("inline", map[string]string{"filename": filename}) + w.Header().Set("Content-Disposition", contentDisposition) + http.ServeFile(w, r, fp) } func (s *SceneServer) ServeScreenshot(scene *models.Scene, w http.ResponseWriter, r *http.Request) {