https://kotlinlang.org logo
#android
Title
# android
i

Ifvwm

01/12/2021, 3:40 AM
I tried to download a file with ktor-client and it failed, please help me https://paste.ubuntu.com/p/s9d68DBKgY/
t

tateisu

01/12/2021, 7:40 AM
Your code trying to convert the response to HttpHeaders doesn't make sense.
client.get<HttpResponse>(imageUrl) {
header("foo","bar")
}.let { res ->
when {
res.status == HttpStatusCode.OK ->
saveFile(imageFile, res.receive<ByteArray>())
else ->
println("get failed. ${res.status} $imageUrl")
}
}
i

Ifvwm

01/12/2021, 9:56 AM
@tateisu thanks