https://kotlinlang.org logo
#ktor
Title
# ktor
l

Lawrence

07/14/2022, 8:31 PM
What would be the equivalent of this curl statement in ktor?
Copy code
curl -X POST \
    $url \
    -H "Accept: application/json" \
    -H "Content-Type: application/octet-stream" \
    --data-binary "@$FILE"
i tried sending the file as body but I quickly ran out of memory with
setBody(file.readBytes()
. Is there a streaming implementation without using MultiPartForm?
a

Aleksei Tirman [JB]

07/15/2022, 4:26 AM
Copy code
val client = HttpClient(Apache)

val response = <http://client.post|client.post>(url) {
    header(HttpHeaders.Accept, ContentType.Application.Json)
    contentType(ContentType.Application.OctetStream)
    setBody(FILE.readChannel())
}
👀 1
27 Views