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

Ifvwm

01/15/2021, 9:10 AM
Copy code
val outputStream = httpClient.put<ByteWriteChannel>(realUrl).toOutputStream()
        outputStream.write("abc".toByteArray())
        outputStream.flush()
        outputStream.close()
why this won't put data to that link? but with httpurlconnection is ok
r

Rustam Siniukov

01/15/2021, 11:57 AM
this might help you https://ktor.io/docs/request.html#specifying-a-body-for-requests TLDR; in your case,
ByteWriteChannel
is type or response body, not request. To send request body use
client.put<ResponseType>(url) { body = ... }
i

Ifvwm

01/15/2021, 12:26 PM
@Rustam Siniukov but I need to handle the uploading process, I mean get the percentage of current uploading, body can do that?
5 Views