How to upload a file using Ktor client
问题 I have read the docs about HTTP requests in Ktor clients, but it lacks of an example of file upload. It mentions PartData.FileItem , but it's unclear how to use it. So, how do I prepare a multipart/form-data request for file upload in Ktor? 回答1: You should use submitFormWithBinaryData's formData parameter to provide a list of parts. There is a helper function with the same name to create such list. HttpClient(Apache).use { client -> val parts: List<PartData> = formData { // Regular form