saket
08/28/2021, 6:59 AMval fileUrl = "<https://file-examples-com.github.io/uploads/2017/04/file_example_MP4_1920_18MG.mp4>"
client.get<HttpStatement>(fileUrl).execute { response ->
val channel = response.receive<ByteReadChannel>()
val time = measureTime {
while (!channel.isClosedForRead) {
val packet = channel.readRemaining(limit = 4_096)
while (!packet.isEmpty) {
packet.readBytes()
}
}
}
println("Streamed file in $time")
}
FWIW I’m using ktor 1.6.1 with ktor-client-ios
on native and ktor-client-okhttp
on jvm.