I am using Ktor 1.2.2 and I have an InputStream object that I want to use as the body for an HttpClient request I make down the line. Up until Ktor 0.95 there was this InputStreamContent object that seemed to do just that but it has been removed from Ktor at version 1.0.0 (couldn't figure out why unfortunately).
I can make it work using a ByteArrayContent (see code below) but I'd rather find a solution that does not require loading the entire InputStream into memory...
ByteArrayContent(input.readAllBytes())
This code is a simple test case that emulate what I'm trying to achieve:
val file = File("c:\\tmp\\foo.pdf")
val inputStream = file.inputStream()
val client = HttpClient(CIO)
client.call(url) {
method = HttpMethod.Post
body = inputStream // TODO: Make this work :(
}
// [... other code that uses the response below]
Let me know if I missed any relevant information,
Thanks!