feat(#920): adopt GET /api/files/stream for seekable audio and video playback (#930)

Co-authored-by: M57 <hy4ri@users.noreply.github.com>
This commit is contained in:
M57
2026-08-18 12:02:36 +03:00
committed by GitHub
co-authored by M57
parent 7232395387
commit 50a0f30d8f
4 changed files with 70 additions and 8 deletions
@@ -76,6 +76,27 @@ class GatewayFileClientTest {
assertFalse(url.contains("MEDIA:"))
}
@Test
fun `buildStreamUrl encodes path and token with stream endpoint`() {
val url = GatewayFileClient.buildStreamUrl(base, tok, "/tmp/video.mp4")!!
assertTrue(url.startsWith("$base/api/files/stream?"))
assertTrue(url.contains("path=%2Ftmp%2Fvideo.mp4"))
assertTrue(url.contains("token="))
}
@Test
fun `buildMediaUrl routes audio and video to stream and others to download`() {
val videoUrl = GatewayFileClient.buildMediaUrl(base, tok, "/tmp/clip.mp4")!!
val audioUrl = GatewayFileClient.buildMediaUrl(base, tok, "/tmp/voice.ogg")!!
val imageUrl = GatewayFileClient.buildMediaUrl(base, tok, "/tmp/photo.jpg")!!
val docUrl = GatewayFileClient.buildMediaUrl(base, tok, "/tmp/report.pdf")!!
assertTrue(videoUrl.startsWith("$base/api/files/stream?"))
assertTrue(audioUrl.startsWith("$base/api/files/stream?"))
assertTrue(imageUrl.startsWith("$base/api/files/download?"))
assertTrue(docUrl.startsWith("$base/api/files/download?"))
}
@Test
fun `normalizePath expands tilde`() {
val home = System.getenv("HOME") ?: "/home/test"