mirror of
https://github.com/InsanusMokrassar/TelegramBotAPI.git
synced 2026-11-03 10:23:01 +00:00
fix way how multipart messages are sending
This commit is contained in:
1 parent
f3fc0769ef
commit
5dbfeca18f
2 files changed
+6
-7
No files matched your search
+2
-4
@@ -5,10 +5,8 @@ import com.github.insanusmokrassar.TelegramBotAPI.requests.abstracts.Request
|
|||||||
import io.ktor.client.HttpClient
|
import io.ktor.client.HttpClient
|
||||||
import io.ktor.client.call.HttpClientCall
|
import io.ktor.client.call.HttpClientCall
|
||||||
import io.ktor.client.call.call
|
import io.ktor.client.call.call
|
||||||
import io.ktor.client.request.accept
|
import io.ktor.client.request.*
|
||||||
import io.ktor.client.request.url
|
import io.ktor.http.*
|
||||||
import io.ktor.http.ContentType
|
|
||||||
import io.ktor.http.HttpMethod
|
|
||||||
|
|
||||||
abstract class AbstractRequestCallFactory : KtorCallFactory {
|
abstract class AbstractRequestCallFactory : KtorCallFactory {
|
||||||
private val methodsCache: MutableMap<String, String> = mutableMapOf()
|
private val methodsCache: MutableMap<String, String> = mutableMapOf()
|
||||||
|
|||||||
+4
-3
@@ -21,14 +21,15 @@ class MultipartRequestCallFactory : AbstractRequestCallFactory() {
|
|||||||
val params = castedRequest.paramsJson.mapWithCommonValues()
|
val params = castedRequest.paramsJson.mapWithCommonValues()
|
||||||
for ((key, value) in castedRequest.mediaMap + params) {
|
for ((key, value) in castedRequest.mediaMap + params) {
|
||||||
when (value) {
|
when (value) {
|
||||||
is MultipartFile -> append(
|
is MultipartFile -> appendInput(
|
||||||
key,
|
key,
|
||||||
value.file.asInput().readBytes(),
|
|
||||||
Headers.build {
|
Headers.build {
|
||||||
append(HttpHeaders.ContentType, value.mimeType)
|
append(HttpHeaders.ContentType, value.mimeType)
|
||||||
append(HttpHeaders.ContentDisposition, "filename=${value.fileId}")
|
append(HttpHeaders.ContentDisposition, "filename=${value.fileId}")
|
||||||
}
|
}
|
||||||
)
|
) {
|
||||||
|
value.file.asInput()
|
||||||
|
}
|
||||||
is FileId -> append(key, value.fileId)
|
is FileId -> append(key, value.fileId)
|
||||||
else -> append(key, value.toString())
|
else -> append(key, value.toString())
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in new issue
Block a user