Sofiane Abbar
07/08/2024, 11:34 AMHeaders.build
within a MultiPartFormDataContent
.
return <http://client.post|client.post>("$API_URL//upload") {
contentType(ContentType.MultiPart.FormData)
setBody(
MultiPartFormDataContent(
formData {
append("type", type)
append("file", image, Headers.build {
append(HttpHeaders.ContentType, "image/*")
append(
HttpHeaders.ContentDisposition,
"filename=$filename"
)
})
},
)
)
}
My server always return HTTPException [Error]: Malformed FormData request. Content-Disposition header in FormData part is missing a name.
Well, I tried to make sure ContentDisposition
is set properly, but when i check the request, it is never send.
Did I miss something?
Thanks a lot 🙏Aleksei Tirman [JB]
07/08/2024, 12:43 PMContentDisposition
like in this example?Sofiane Abbar
07/08/2024, 4:01 PMappend("file", image, Headers.build {
append(HttpHeaders.ContentType, "image/*")
append(HttpHeaders.ContentDisposition, "filename=\"$filename\"")
})
Worth to mention that Postman works properlySofiane Abbar
07/08/2024, 4:15 PMonUpload
the size sent from the phone and what's receive on the server is same.
But I am still getting HTTPException [Error]: Malformed FormData request. Content-Disposition header in FormData part is missing a name.
Aleksei Tirman [JB]
07/08/2024, 8:26 PMSofiane Abbar
07/09/2024, 7:46 AMContent-Disposition: form-data; name=*"type"*\r\n
vs Ktor Content-Disposition: form-data; name=*type*\r\n
I had to add \"
between the append name.
MultiPartFormDataContent(
formData {
append("\"type\"", type)
Thanks!
Don't know if there is any RFC related to this