https://kotlinlang.org logo
#ktor
Title
# ktor
o

otsuka

04/02/2019, 2:38 AM
I would like to download a big file using Ktor client and save it. I don’t know how to use
ByteReadChannel
. Is there an example code which writes contents to a file from
ByteReadChannel
? https://ktor.io/clients/http-client/calls/responses.html#HttpResponse
g

gildor

04/02/2019, 2:42 AM
it shows how to write to temporary file, but you can easily modify it to use permanent file
o

otsuka

04/02/2019, 2:50 AM
Thanks!
call.response.content.copyAndClose(file.writeChannel())
This one line is really helpful to me.
12 Views