mirror of
https://github.com/stashapp/stash.git
synced 2025-12-06 08:26:00 +01:00
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>
This commit is contained in:
parent
c5bad48ece
commit
2ed9e5332d
1 changed files with 8 additions and 3 deletions
|
|
@ -3,7 +3,9 @@ package manager
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"errors"
|
"errors"
|
||||||
|
"mime"
|
||||||
"net/http"
|
"net/http"
|
||||||
|
"path/filepath"
|
||||||
|
|
||||||
"github.com/stashapp/stash/internal/manager/config"
|
"github.com/stashapp/stash/internal/manager/config"
|
||||||
"github.com/stashapp/stash/internal/static"
|
"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())
|
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)
|
streamRequestCtx := ffmpeg.NewStreamRequestContext(w, r)
|
||||||
|
|
||||||
// #2579 - hijacking and closing the connection here causes video playback to fail in Safari
|
// #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
|
// We trust that the request context will be closed, so we don't need to call Cancel on the
|
||||||
// returned context here.
|
// returned context here.
|
||||||
_ = GetInstance().ReadLockManager.ReadLock(streamRequestCtx, filepath)
|
_ = GetInstance().ReadLockManager.ReadLock(streamRequestCtx, fp)
|
||||||
http.ServeFile(w, r, filepath)
|
_, 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) {
|
func (s *SceneServer) ServeScreenshot(scene *models.Scene, w http.ResponseWriter, r *http.Request) {
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue