Aleksandr Ivanov
08/09/2021, 2:07 PMclient_mpp
example and found that for ByteArray with size 100 problem is not happened, but for size 200 I got an exception.
here is the code of modified ApplicationApi
@SharedImmutable
internal expect val ApplicationDispatcher: CoroutineDispatcher
class ApplicationApi {
// 100 - ok, 200 - kotlin.native.concurrent.InvalidMutabilityException: mutation attempt of frozen <object>
private val SIZE = 200;
private val client = HttpClient()
private val address = Url("<https://cors-test.appspot.com/test>")
fun about(callback: (String) -> Unit) {
GlobalScope.launch(ApplicationDispatcher) {
val result: String = <http://client.post|client.post> {
url(address.toString())
val filename = "test"
val mimeType = "image/png"
val filePart = formData {
val key = "photo"
val headers = Headers.build {
append(HttpHeaders.ContentDisposition, "filename=$filename;type=$mimeType")
}
append(key, ByteArray(SIZE), headers)
}
body = MultiPartFormDataContent(filePart)
}
callback(result)
}
}
}
Aleksei Tirman [JB]
08/09/2021, 6:21 PMAleksandr Ivanov
08/09/2021, 6:22 PMAleksei Tirman [JB]
08/10/2021, 4:19 PMAleksandr Ivanov
08/11/2021, 2:22 PMAleksei Tirman [JB]
08/11/2021, 3:29 PM