|
|
@ -121,12 +121,11 @@ fun Request.Builder.postForm(form: Map<String, String>, encoded: Boolean = false |
|
|
|
fun Request.Builder.postMultipart(type: String, form: Map<String, Any>) { |
|
|
|
fun Request.Builder.postMultipart(type: String, form: Map<String, Any>) { |
|
|
|
val multipartBody = MultipartBody.Builder().setType(type.toMediaType()) |
|
|
|
val multipartBody = MultipartBody.Builder().setType(type.toMediaType()) |
|
|
|
form.forEach { |
|
|
|
form.forEach { |
|
|
|
when (it.value) { |
|
|
|
when (val value = it.value) { |
|
|
|
is Triple<*, *, *> -> { |
|
|
|
is Map<*, *> -> { |
|
|
|
val triple = it.value as Triple<*, *, *> |
|
|
|
val fileName = value["fileName"] as String |
|
|
|
val fileName = triple.first!!.toString() |
|
|
|
val file = value["file"] as ByteArray |
|
|
|
val file = triple.second as ByteArray |
|
|
|
val mediaType = (value["contentType"] as? String)?.toMediaType() |
|
|
|
val mediaType = triple.third?.toString()?.toMediaType() |
|
|
|
|
|
|
|
val requestBody = file.toRequestBody(mediaType) |
|
|
|
val requestBody = file.toRequestBody(mediaType) |
|
|
|
multipartBody.addFormDataPart(it.key, fileName, requestBody) |
|
|
|
multipartBody.addFormDataPart(it.key, fileName, requestBody) |
|
|
|
} |
|
|
|
} |
|
|
|