diff --git a/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/bot/Ktor/base/AbstractRequestCallFactory.kt b/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/bot/Ktor/base/AbstractRequestCallFactory.kt index c924a84bd6..b843a61d34 100644 --- a/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/bot/Ktor/base/AbstractRequestCallFactory.kt +++ b/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/bot/Ktor/base/AbstractRequestCallFactory.kt @@ -5,10 +5,8 @@ import com.github.insanusmokrassar.TelegramBotAPI.requests.abstracts.Request import io.ktor.client.HttpClient import io.ktor.client.call.HttpClientCall import io.ktor.client.call.call -import io.ktor.client.request.accept -import io.ktor.client.request.url -import io.ktor.http.ContentType -import io.ktor.http.HttpMethod +import io.ktor.client.request.* +import io.ktor.http.* abstract class AbstractRequestCallFactory : KtorCallFactory { private val methodsCache: MutableMap = mutableMapOf() diff --git a/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/bot/Ktor/base/MultipartRequestCallFactory.kt b/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/bot/Ktor/base/MultipartRequestCallFactory.kt index 5884104497..3a3ccf97bb 100644 --- a/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/bot/Ktor/base/MultipartRequestCallFactory.kt +++ b/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/bot/Ktor/base/MultipartRequestCallFactory.kt @@ -21,14 +21,15 @@ class MultipartRequestCallFactory : AbstractRequestCallFactory() { val params = castedRequest.paramsJson.mapWithCommonValues() for ((key, value) in castedRequest.mediaMap + params) { when (value) { - is MultipartFile -> append( + is MultipartFile -> appendInput( key, - value.file.asInput().readBytes(), Headers.build { append(HttpHeaders.ContentType, value.mimeType) append(HttpHeaders.ContentDisposition, "filename=${value.fileId}") } - ) + ) { + value.file.asInput() + } is FileId -> append(key, value.fileId) else -> append(key, value.toString()) }