1
0
mirror of https://github.com/InsanusMokrassar/TelegramBotAPI.git synced 2024-12-23 00:57:13 +00:00

fix way how multipart messages are sending

This commit is contained in:
InsanusMokrassar 2019-12-03 12:15:15 +06:00
parent f3fc0769ef
commit 5dbfeca18f
2 changed files with 6 additions and 7 deletions

View File

@ -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<String, String> = mutableMapOf()

View File

@ -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())
}