mirror of
https://github.com/InsanusMokrassar/TelegramBotAPI.git
synced 2024-12-22 16:47:13 +00:00
MPPFile#asMultipartFile
This commit is contained in:
parent
5d6ba0f59e
commit
807952201b
@ -9,6 +9,7 @@
|
||||
* `Core`:
|
||||
* `MultipartRequestCallFactory` now will use file name as multipart `filename` parameter instead of generated
|
||||
filename
|
||||
* New extension `MPPFile#asMultipartFile`
|
||||
|
||||
## 0.35.7
|
||||
|
||||
|
@ -1,7 +1,9 @@
|
||||
package dev.inmo.tgbotapi.requests.abstracts
|
||||
|
||||
import dev.inmo.micro_utils.common.MPPFile
|
||||
import dev.inmo.tgbotapi.utils.*
|
||||
import io.ktor.utils.io.ByteReadChannel
|
||||
import io.ktor.utils.io.core.Input
|
||||
import kotlinx.serialization.KSerializer
|
||||
import kotlinx.serialization.Serializable
|
||||
import kotlinx.serialization.descriptors.*
|
||||
@ -75,3 +77,5 @@ suspend inline fun ByteReadChannel.asMultipartFile(
|
||||
suspend inline fun ByteReadChannelAllocator.asMultipartFile(
|
||||
fileName: String
|
||||
) = this.invoke().asMultipartFile(fileName)
|
||||
|
||||
expect suspend fun MPPFile.asMultipartFile(): MultipartFile
|
||||
|
@ -0,0 +1,8 @@
|
||||
package dev.inmo.tgbotapi.requests.abstracts
|
||||
|
||||
import dev.inmo.micro_utils.common.*
|
||||
import io.ktor.utils.io.ByteReadChannel
|
||||
|
||||
actual suspend fun MPPFile.asMultipartFile(): MultipartFile = ByteReadChannel(bytes()).asMultipartFile(
|
||||
filename.name
|
||||
)
|
@ -0,0 +1,5 @@
|
||||
package dev.inmo.tgbotapi.requests.abstracts
|
||||
|
||||
import dev.inmo.micro_utils.common.MPPFile
|
||||
|
||||
actual suspend fun MPPFile.asMultipartFile(): MultipartFile = toInputFile()
|
Loading…
Reference in New Issue
Block a user