Skip to content

Commit

Permalink
InputFile kdocs improvements
Browse files Browse the repository at this point in the history
  • Loading branch information
InsanusMokrassar committed May 18, 2023
1 parent ed2c447 commit f07a179
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 0 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
* `Versions`:
* `Serialization`: `1.5.0` -> `1.5.1`
* `MicroUtils`: `0.18.1` -> `0.18.4`
* `Core`:
* Actualize kdocs in `InputFile`
* `BehaviourBuilder`:
* Now it is possible to use `waitMediaContent`/`waitMediaContentMessage`/`onMediaContent`
* Add `onMention`/`waitMention` functionality
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,11 @@ import kotlinx.serialization.encoding.Encoder
* @see ByteArray.asMultipartFile
* @see ByteReadChannel.asMultipartFile
* @see ByteReadChannelAllocator.asMultipartFile
*
* @see fromInput
* @see fromFile
* @see fromId
* @see fromUrl
*/
@Serializable(InputFileSerializer::class)
sealed class InputFile {
Expand All @@ -29,9 +34,24 @@ sealed class InputFile {
companion object {
operator fun invoke(file: MPPFile) = file.asMultipartFile()

/**
* Creates [MultipartFile] based on incoming [filename] and [inputSource]
*/
fun fromInput(filename: String, inputSource: () -> Input) = MultipartFile(filename, inputSource)

/**
* Creates [MultipartFile] based on incoming [MPPFile] (common File in java, for example)
*/
fun fromFile(file: MPPFile) = invoke(file)

/**
* Creates [FileId] from the incomming [id] [String] with believe that it is [FileId]
*/
fun fromId(id: String) = FileId(id)

/**
* Creates [FileUrl] from the incomming [url] [String]
*/
fun fromUrl(url: String) = FileUrl(url)
}
}
Expand Down

0 comments on commit f07a179

Please sign in to comment.