any way to turn a `org.w3c.files.File` into an `In...
# ktor
a
any way to turn a
org.w3c.files.File
into an
Input
so that I can upload in a multiform ktor client request?
s
I think you'll need to use
FileReader
to read its contents into a
ByteArray
.
a
Unfortunately, it's not possible to convert
org.w3c.files.File
to
Input
because the request body cannot be streamed in a browser. You can read the file into
Uint8Array
and then convert it to a
ByteArray
with the following code:
Copy code
fun Uint8Array.asByteArray(): ByteArray {
    return Int8Array(buffer, byteOffset, length).asDynamic()
}
👍 3
a
I ended up sending it as ByteArray. (non input)