mirror of
https://github.com/InsanusMokrassar/TelegramBotAPI.git
synced 2024-11-26 03:58:44 +00:00
hotfix
This commit is contained in:
parent
f42cf78969
commit
f7d2c8bbd2
@ -4,6 +4,8 @@
|
|||||||
|
|
||||||
* `Core`:
|
* `Core`:
|
||||||
* Several new extensions `ByteReadChannel#asStorageFile` and `ByteReadChannelAllocator#asStorageFile`
|
* Several new extensions `ByteReadChannel#asStorageFile` and `ByteReadChannelAllocator#asStorageFile`
|
||||||
|
* Several new extensions `ByteArray#asMultipartFile`, `ByteReadChannel#asMultipartFile` and
|
||||||
|
`ByteReadChannelAllocator#asMultipartFile`
|
||||||
* `API`:
|
* `API`:
|
||||||
* New extensions `TelegramBot#downloadFile` for writing of incoming bytes to the file
|
* New extensions `TelegramBot#downloadFile` for writing of incoming bytes to the file
|
||||||
* New extensions `TelegramBot#downloadFileStream` and `TelegramBot#downloadFileStreamAllocator` for getting of input
|
* New extensions `TelegramBot#downloadFileStream` and `TelegramBot#downloadFileStreamAllocator` for getting of input
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
package dev.inmo.tgbotapi.requests.abstracts
|
package dev.inmo.tgbotapi.requests.abstracts
|
||||||
|
|
||||||
import dev.inmo.tgbotapi.utils.RiskFeature
|
import dev.inmo.tgbotapi.utils.*
|
||||||
import dev.inmo.tgbotapi.utils.StorageFile
|
import io.ktor.utils.io.ByteReadChannel
|
||||||
import kotlinx.serialization.KSerializer
|
import kotlinx.serialization.KSerializer
|
||||||
import kotlinx.serialization.Serializable
|
import kotlinx.serialization.Serializable
|
||||||
import kotlinx.serialization.descriptors.*
|
import kotlinx.serialization.descriptors.*
|
||||||
@ -42,6 +42,8 @@ object InputFileSerializer : KSerializer<InputFile> {
|
|||||||
// TODO:: add checks for files size
|
// TODO:: add checks for files size
|
||||||
/**
|
/**
|
||||||
* Contains info about file for sending
|
* Contains info about file for sending
|
||||||
|
*
|
||||||
|
* @see asMultipartFile
|
||||||
*/
|
*/
|
||||||
@Serializable(InputFileSerializer::class)
|
@Serializable(InputFileSerializer::class)
|
||||||
data class MultipartFile (
|
data class MultipartFile (
|
||||||
@ -51,3 +53,22 @@ data class MultipartFile (
|
|||||||
) : InputFile() {
|
) : InputFile() {
|
||||||
override val fileId: String = file.storageFileInfo.generateCustomName()
|
override val fileId: String = file.storageFileInfo.generateCustomName()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@Suppress("NOTHING_TO_INLINE", "unused")
|
||||||
|
inline fun ByteArray.asMultipartFile(
|
||||||
|
fileName: String,
|
||||||
|
mimeType: MimeType
|
||||||
|
) = MultipartFile(asStorageFile(fileName, mimeType))
|
||||||
|
|
||||||
|
@Suppress("NOTHING_TO_INLINE", "unused")
|
||||||
|
suspend inline fun ByteReadChannel.asMultipartFile(
|
||||||
|
fileName: String,
|
||||||
|
mimeType: MimeType
|
||||||
|
) = MultipartFile(asStorageFile(fileName, mimeType))
|
||||||
|
|
||||||
|
@Suppress("NOTHING_TO_INLINE", "unused")
|
||||||
|
suspend inline fun ByteReadChannelAllocator.asMultipartFile(
|
||||||
|
fileName: String,
|
||||||
|
mimeType: MimeType
|
||||||
|
) = this.invoke().asMultipartFile(fileName, mimeType)
|
||||||
|
Loading…
Reference in New Issue
Block a user