Media: keep the name of the file when possible
This commit is contained in:
parent
2682d1c2b4
commit
458cd2d4f3
10 changed files with 90 additions and 31 deletions
|
|
@ -27,7 +27,8 @@ interface MediaPreProcessor {
|
|||
suspend fun process(
|
||||
uri: Uri,
|
||||
mimeType: String,
|
||||
deleteOriginal: Boolean = false
|
||||
deleteOriginal: Boolean = false,
|
||||
compressIfPossible: Boolean
|
||||
): Result<MediaUploadInfo>
|
||||
|
||||
data class Failure(override val cause: Throwable?) : RuntimeException(cause)
|
||||
|
|
|
|||
|
|
@ -26,9 +26,14 @@ class MediaSender @Inject constructor(
|
|||
private val room: MatrixRoom,
|
||||
) {
|
||||
|
||||
suspend fun sendMedia(uri: Uri, mimeType: String): Result<Unit> {
|
||||
suspend fun sendMedia(uri: Uri, mimeType: String, compressIfPossible: Boolean): Result<Unit> {
|
||||
return preProcessor
|
||||
.process(uri, mimeType, deleteOriginal = true)
|
||||
.process(
|
||||
uri = uri,
|
||||
mimeType = mimeType,
|
||||
deleteOriginal = true,
|
||||
compressIfPossible = compressIfPossible
|
||||
)
|
||||
.flatMap { info ->
|
||||
room.sendMedia(info)
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue