Any pointers towards how to create a stream from o...
# squarelibraries
a
Any pointers towards how to create a stream from okio so that i can post a file via ktor client in kotlin multiplatform? Can't seem to figure out the wiring
j
FileSystem.SYSTEM.source(“path/to/file.txt”).source().buffer().inputStream()
a
thanks @jessewilson. forgot to mention this is for kotlin multiplatform.
InputStream
is a java API so can't use it
Also asked in #ktor at https://kotlinlang.slack.com/archives/C0A974TJ9/p1711093509194449 Got a good hint about the wiring. seems like I am missing a
buffer
to
input
. will have a look how the
.inputStream()
and
.asInput()
works under the hood and will try to do a
buffer().asInput()
tomorrow.
v
a
@vanniktech maybe? Im not sure what
ByteReadChannel
is or how to get it. I ended up figuring out the wiring though: https://kotlinlang.slack.com/archives/C0A974TJ9/p1711121156524589?thread_ts=1711093509.194449&cid=C0A974TJ9
v
For streaming from ktor you can use the
prepareGet().execute
and
prepareFormWithBinaryData().execute
methods and from those you get the types which you can map onto the okio's equivalent
c
did you ever figure this out?
a
i shared my solution above
👍 1