hi there.
I found an example of file uploading with ktor as a multiPart request.
What if the file name contains special characters?
like Übung 001.pdf
val client = HttpClient(CIO)
val response: HttpResponse = client.post("http://localhost:8080/upload") {
setBody(MultiPartFormDataContent(
formData {
append("description", "Ktor logo")
append("image", File("ktor_logo.png").readBytes(), Headers.build {
append(HttpHeaders.ContentType, "image/png")
append(HttpHeaders.ContentDisposition, "filename=Übung 001.pdf")
})
},
boundary = "WebAppBoundary"
)
)
onUpload { bytesSentTotal, contentLength ->
println("Sent $bytesSentTotal bytes from $contentLength")
}
}
Would
"filename=Übung 001.pdf"
automatically be encoded or should I use any function for it?
I thought, that file name should be at least double-quoted:
https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Disposition