【问题标题】:Multipart upload list files分段上传列表文件
【发布时间】:2021-01-25 16:01:00
【问题描述】:

如何使用 ktor 从客户端上传列表文件?

我试试:

newPostDto.images.map {
    append("images", it)
}

但它的变体不起作用。

【问题讨论】:

    标签: kotlin-multiplatform ktor kotlin-multiplatform-mobile


    【解决方案1】:

    这是一个示例(有关更多信息,您可以查看 this repo 以获取完整的图像文件上传示例)

    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")
        }
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2016-06-06
      • 2021-01-23
      • 2014-08-08
      • 1970-01-01
      • 2020-01-07
      • 2021-04-15
      • 2013-11-17
      相关资源
      最近更新 更多