Hello folks! I am stumped by something I have not been able to figure out myself despite considerable experimentation and googling.
In a nutshell, what I want to do is feed an InputStream as the body of a PUT request. I thought I could maybe use a ChannelWriterContent and provide a block that writes to the ByteWriteChannel but that was a bust. I can obviously readBytes() from the InputStream, but the stream can be arbitrarily large and I do not want to shove everything in memory.
I don’t think this is a bad solution. It does exactly what it should - it reads body from your input stream. I would probably verify that InputStream is automatically closed, but I guess it is.
Anyway, if for some reason you prefer to use ChannelWriterContent then you just need to write while reading - instead of reading the whole stream with readBytes(). You can do it manually, by creating a buffer, then reading and writing. You can also use existing copyTo() extension:
override suspend fun writeTo(channel: ByteWriteChannel) {
inputStream.copyTo(channel)
}
<Error><Code>NotImplemented</Code><Message>A header you provided implies functionality that is not implemented</Message><Header>Transfer-Encoding</Header><RequestId>xxxxx</RequestId><HostId>xxxxx</HostId></Error>"