Are there any good examples on how to do streaming...
# ktor
j
Are there any good examples on how to do streaming (body) uploads?
a
Here is an example of streaming a request body that is read from a file:
Copy code
import io.ktor.client.*
import io.ktor.client.engine.apache.*
import io.ktor.client.features.cache.*
import io.ktor.client.request.*
import io.ktor.util.cio.*
import java.io.File

suspend fun main() {
    val client = HttpClient(Apache) {
        install(HttpCache)
    }

    val file = File("/path/to/file")

    val r = <http://client.post|client.post><String>("<https://httpbin.org/post>") {
        body = file.readChannel()
    }

    println(r)
}