1
0
mirror of https://github.com/InsanusMokrassar/TelegramBotAPI.git synced 2024-11-25 19:48:43 +00:00

add calculation of mimed type from TelegramMediaFile when it is MimedFile

This commit is contained in:
InsanusMokrassar 2021-08-13 11:43:36 +06:00
parent f147a3d620
commit 17806cde25

View File

@ -1,6 +1,7 @@
package dev.inmo.tgbotapi.extensions.utils.types.files
import dev.inmo.tgbotapi.bot.TelegramBot
import dev.inmo.tgbotapi.extensions.utils.asMimedMediaFile
import dev.inmo.tgbotapi.requests.DownloadFileStream
import dev.inmo.tgbotapi.requests.abstracts.FileId
import dev.inmo.tgbotapi.requests.get.GetFile
@ -35,7 +36,9 @@ suspend fun TelegramBot.convertToStorageFile(
suspend fun TelegramBot.convertToStorageFile(
file: TelegramMediaFile
): StorageFile = convertToStorageFile(file.fileId)
): StorageFile = file.asMimedMediaFile() ?.mimeType ?.let {
convertToStorageFile(file.fileId, it)
} ?: convertToStorageFile(file.fileId)
suspend fun TelegramBot.convertToStorageFile(
content: MediaContent