Issue when try to upload file using ktor client

38 Views Asked by At

I got java.net.ProtocolException: unexpected end of stream when try to upload img file to server

val response = httpClient.submitFormWithBinaryData(
            url = BASE_URL + "files/upload",
            formData = formData {
                append("image", file!!.readBytes(), Headers.build {
                    append(HttpHeaders.ContentType, "image/png")
                    append(HttpHeaders.ContentDisposition, "filename=\"ktor_logo.png\"")
                })
            }
        )

How to solve that ?

0

There are 0 best solutions below