Reputation: 201
How I can upload list files from the client with ktor?
I try:
newPostDto.images.map {
append("images", it)
}
But its variant does not work.
Upvotes: 1
Views: 1325
Reputation: 7700
Here's an example (for more information you could check out this repo for a complete image file upload example)
client.submitFormWithBinaryData(
formData {
appendInput(key = ICON_FILE_PART, headers = Headers.build {
append(HttpHeaders.ContentDisposition, "filename=${appId}_ic")
}) {
buildPacket { writeFully(icon.toByteArray()) }
}
}) {
apiUrl("$APPLICATIONS_BASE_URL/${appId}/icon")
}
Upvotes: 2