From 17806cde25e941d379ea209da23882b415c400ec Mon Sep 17 00:00:00 2001 From: InsanusMokrassar Date: Fri, 13 Aug 2021 11:43:36 +0600 Subject: [PATCH] add calculation of mimed type from TelegramMediaFile when it is MimedFile --- .../utils/types/files/AdditionalContentAsStorageFile.kt | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/tgbotapi.extensions.utils/src/jvmMain/kotlin/dev/inmo/tgbotapi/extensions/utils/types/files/AdditionalContentAsStorageFile.kt b/tgbotapi.extensions.utils/src/jvmMain/kotlin/dev/inmo/tgbotapi/extensions/utils/types/files/AdditionalContentAsStorageFile.kt index db1229cadb..927e7d4c19 100644 --- a/tgbotapi.extensions.utils/src/jvmMain/kotlin/dev/inmo/tgbotapi/extensions/utils/types/files/AdditionalContentAsStorageFile.kt +++ b/tgbotapi.extensions.utils/src/jvmMain/kotlin/dev/inmo/tgbotapi/extensions/utils/types/files/AdditionalContentAsStorageFile.kt @@ -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