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

Hamza GATTAL

08/13/2022, 6:53 PM
Hi everyone Could you please give me an example how to download a file using ktor client.
d

Dominaezzz

08/13/2022, 7:07 PM
client.get("https://.......").body<ByteArray>()
b

Big Chungus

08/13/2022, 7:12 PM
Then write the ByteArray to File
n

Nikky

08/13/2022, 8:15 PM
there is also
bodyAsChannel
variant which will get you a
ByteReadChannel
b

Big Chungus

08/13/2022, 8:16 PM
Yeah good tip, i usually just feed the read channel into file write channel
2 Views