Nacho Ruiz Martin
05/31/2024, 3:46 PMMultiPartFormDataContent
to set the boy of a request in the like:
setBody(
MultiPartFormDataContent(
formData {
append("pub_id", pubId)
append("logo", logo, Headers.build {
append(HttpHeaders.ContentType, contentType)
append(HttpHeaders.ContentDisposition, "filename=\"$logoName\"")
})
}
)
)
on the server side (not Ktor) I’m getting the following:
{
fields: {
"nt-Disposition: form-data; name=pub_id\r\nContent-Length: ": "30"
},
files: {
"nt-Disposition: form-data; name=log": {
name: "nt-Disposition: form-data; name=log",
filename: "Foto May 14 2024.jpg",
contentType: "image/jpeg\r\nContent-Length: 6371508",
size: 6371508,
content: Uint8Array(6371508) [...]
}
}
}
As you can see, the Content-Disposition header is interpreted as part of the parameters and everything gets messy.
The server side is working as expected when sending the request with Postman, though.
Any idea what could be happening?
Thanks!Nacho Ruiz Martin
05/31/2024, 3:48 PMaddFormDataPart("logo","Foto May 14 2024.jpg",
RequestBody.create(MediaType.parse("application/octet-stream"),
new File("/Users/ignacio.ruizmartin/Downloads/Foto May 14 2024.jpg")))
I’m surprised about the application/octet-stream
part, shouldn’t that be the Mime Type of the file?Nacho Ruiz Martin
05/31/2024, 3:56 PMAleksei Tirman [JB]
06/03/2024, 7:48 AMNacho Ruiz Martin
06/03/2024, 9:46 AMNacho Ruiz Martin
06/05/2024, 10:20 AMNacho Ruiz Martin
06/05/2024, 10:21 AMNacho Ruiz Martin
06/05/2024, 10:21 AM