ritesh
05/29/2020, 12:27 PMByteArray
and then passing it in the multipart block but server is not accepting it as a multipart request but sees it like a regular post call (and the API is working fine on postman),
val data: ByteArray = ...
val urlString: String = ...
httpClient.request<T>(urlString) {
method = <http://HttpMethod.Post|HttpMethod.Post>
body = MultiPartFormDataContent(
formData {
append("avatar", data)
}
)
}
Can someone point me to right direction what could be wrong/missing here? Is there some other way to upload an image? Do we have to manually set "Content-Type"
as multipart/form-data
somewhere? 🤔e5l
05/29/2020, 3:39 PMByteArrayContent
body with Content-Type
param u need.ritesh
05/29/2020, 5:36 PMContent-Disposition
as header for multipart to work.
body = MultiPartFormDataContent(
formData {
append(
"avatar",
data,
Headers.build {
append(HttpHeaders.ContentDisposition, "filename=<name>")
}
)
}
)