Hey there! Does anyone know how to read a `ByteRea...
# ktor
p
Hey there! Does anyone know how to read a
ByteReadChannel
twice? The idea is that the server returns a stream, the client exposes it as a
ByteReadChannel
so it can be consumed by the media player right away (streaming) and we'd like to reuse the channel to copy the stream into a file after the playback (to avoid the need of re-requesting the backend), but debugging the code after the media player is done,
byteReadChannel.isClosedForRead
is
true
so can't be "reused" to copy into a file, we understand that
ByteReadChannel
is single-reader so any ideas as to how we can stream to the media player immediately and then reuse the response somehow to copy it to a file after the player finishes? Thanks in advance! Cc @Aleksei Tirman [JB]
1
Found a solution using
ByteArray
🎉 rubber duck
a
Also, if you don't call a method for streaming the response body, it's saved automatically so you can read the channel multiple times.
p
What do you mean?
a
Nevermind. I was wrong.
👍 1