I’m a bit confused as how to download a file with ...
# coroutines
u
I’m a bit confused as how to download a file with retrofit (okhttp) and coroutines so I declare the api
Copy code
interface SpeedApi {
    @Streaming
    @GET
    suspend fun download(@Url url: String): Response<ResponseBody>
}

val response = speedApi.download("...")
response.body.use {
   it.byteStream().copyTo(...)
}
works, but the stream copying makes that blocking, and therefore not cancellable