mirror of
https://github.com/InsanusMokrassar/TelegramBotAPI.git
synced 2025-09-03 07:09:23 +00:00
fixes
This commit is contained in:
@@ -1,5 +1,6 @@
|
|||||||
package dev.inmo.tgbotapi.bot.Ktor.base
|
package dev.inmo.tgbotapi.bot.Ktor.base
|
||||||
|
|
||||||
|
import dev.inmo.micro_utils.coroutines.launchSafelyWithoutExceptions
|
||||||
import dev.inmo.tgbotapi.bot.Ktor.KtorCallFactory
|
import dev.inmo.tgbotapi.bot.Ktor.KtorCallFactory
|
||||||
import dev.inmo.tgbotapi.requests.DownloadFileStream
|
import dev.inmo.tgbotapi.requests.DownloadFileStream
|
||||||
import dev.inmo.tgbotapi.requests.abstracts.Request
|
import dev.inmo.tgbotapi.requests.abstracts.Request
|
||||||
@@ -26,10 +27,10 @@ object DownloadFileChannelRequestCallFactory : KtorCallFactory {
|
|||||||
ByteReadChannelAllocator {
|
ByteReadChannelAllocator {
|
||||||
val scope = CoroutineScope(coroutineContext)
|
val scope = CoroutineScope(coroutineContext)
|
||||||
val outChannel = ByteChannel()
|
val outChannel = ByteChannel()
|
||||||
scope.launch {
|
scope.launchSafelyWithoutExceptions {
|
||||||
client.get<HttpStatement>(fullUrl).execute { httpResponse ->
|
client.get<HttpStatement>(fullUrl).execute { httpResponse ->
|
||||||
val channel: ByteReadChannel = httpResponse.receive()
|
val channel: ByteReadChannel = httpResponse.receive()
|
||||||
channel.copyTo(outChannel)
|
channel.copyAndClose(outChannel)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
outChannel
|
outChannel
|
||||||
|
Reference in New Issue
Block a user