From 1ee5b4bfd45239f6719f9193e8ce6afc58efe12e Mon Sep 17 00:00:00 2001 From: InsanusMokrassar Date: Tue, 14 Dec 2021 21:13:11 +0600 Subject: [PATCH] hotfix for multipart --- .../micro_utils/ktor/server/ServerRoutingShortcuts.kt | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/ktor/server/src/jvmMain/kotlin/dev/inmo/micro_utils/ktor/server/ServerRoutingShortcuts.kt b/ktor/server/src/jvmMain/kotlin/dev/inmo/micro_utils/ktor/server/ServerRoutingShortcuts.kt index 4886e22bb20..d4dd303616f 100644 --- a/ktor/server/src/jvmMain/kotlin/dev/inmo/micro_utils/ktor/server/ServerRoutingShortcuts.kt +++ b/ktor/server/src/jvmMain/kotlin/dev/inmo/micro_utils/ktor/server/ServerRoutingShortcuts.kt @@ -19,6 +19,7 @@ import io.ktor.utils.io.core.Input import io.ktor.utils.io.core.readBytes import kotlinx.coroutines.flow.Flow import kotlinx.serialization.* +import java.io.File import java.io.File.createTempFile class UnifiedRouter( @@ -180,7 +181,9 @@ suspend fun ApplicationCall.uniloadMultipartFile( resultInput = MPPFile.createTempFile( name.nameWithoutExtension, ".${name.extension}" - ) + ).apply { + writeBytes(it.provider().readBytes()) + } } "data" -> data = standardKtorSerialFormat.decodeDefault(deserializer, it.provider().readBytes()).optional else -> onCustomFileItem(it) @@ -212,7 +215,9 @@ suspend fun ApplicationCall.uniloadMultipartFile( resultInput = MPPFile.createTempFile( name.nameWithoutExtension, ".${name.extension}" - ) + ).apply { + writeBytes(it.provider().readBytes()) + } } else { onCustomFileItem(it) }