https://kotlinlang.org logo
#squarelibraries
Title
# squarelibraries
a

Alex Styl

03/22/2024, 3:38 AM
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

jessewilson

03/22/2024, 11:37 AM
FileSystem.SYSTEM.source(“path/to/file.txt”).source().buffer().inputStream()
a

Alex Styl

03/22/2024, 2:48 PM
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

vanniktech

03/23/2024, 9:48 PM
a

Alex Styl

03/24/2024, 6:55 AM
@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

vanniktech

03/25/2024, 9:32 PM
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

Colton Idle

04/07/2024, 5:27 AM
did you ever figure this out?
a

Alex Styl

04/07/2024, 9:10 AM
i shared my solution above
👍 1