Add range request support to publicFileViewHandler for video/audio seeking

This commit is contained in:
Leon Bösche
2026-01-25 03:23:59 +01:00
parent e7b222bc7d
commit 08fc0906c0

View File

@@ -3175,7 +3175,7 @@ func publicFileViewHandler(w http.ResponseWriter, r *http.Request, db *database.
}
// Stream file
resp, err := client.Download(r.Context(), file.Path, "")
resp, err := client.Download(r.Context(), file.Path, r.Header.Get("Range"))
if err != nil {
errors.LogError(r, err, "Failed to download file")
errors.WriteError(w, errors.CodeInternal, "Server error", http.StatusInternalServerError)
@@ -3188,6 +3188,9 @@ func publicFileViewHandler(w http.ResponseWriter, r *http.Request, db *database.
w.Header().Set("Access-Control-Allow-Methods", "GET, HEAD, OPTIONS")
w.Header().Set("Access-Control-Allow-Headers", "Range")
// Set status code (200 or 206 for partial)
w.WriteHeader(resp.StatusCode)
// Copy headers from Nextcloud response, but skip Content-Type to ensure correct MIME type
for k, v := range resp.Header {
if k != "Content-Type" {