mirror of
https://github.com/Novaloop-AG/element-x-android.git
synced 2026-11-02 21:05:28 +00:00
Send a concrete mime type for media shared with a wildcard one
Some apps share an image with the mime type image/* rather than a concrete one. That value was carried straight into the uploaded event, so the message reached the room with an unusable media type and bridges rejected it as unsupported. Resolve a wildcard subtype to a default for its top level type before processing the upload, reusing the mapping the download path already applies so the SDK can pick the right extension.
This commit is contained in:
+3
-10
@@ -11,7 +11,7 @@ package io.element.android.libraries.matrix.impl.media
|
||||
import io.element.android.libraries.core.coroutine.CoroutineDispatchers
|
||||
import io.element.android.libraries.core.extensions.mapFailure
|
||||
import io.element.android.libraries.core.extensions.runCatchingExceptions
|
||||
import io.element.android.libraries.core.mimetype.MimeTypes
|
||||
import io.element.android.libraries.core.mimetype.MimeTypes.withDefaultSubtype
|
||||
import io.element.android.libraries.matrix.api.media.MatrixMediaLoader
|
||||
import io.element.android.libraries.matrix.api.media.MediaFile
|
||||
import io.element.android.libraries.matrix.api.media.MediaSource
|
||||
@@ -71,15 +71,8 @@ class RustMediaLoader(
|
||||
val mediaFile = innerClient.getMediaFile(
|
||||
mediaSource = mediaSource,
|
||||
filename = filename,
|
||||
mimeType = when {
|
||||
mimeType == null -> MimeTypes.OctetStream
|
||||
MimeTypes.hasSubtype(mimeType) -> mimeType
|
||||
// Fallback to a default mime type based on the main type, so that the SDK can create a file with the correct extension.
|
||||
mimeType == MimeTypes.Images -> MimeTypes.Jpeg
|
||||
mimeType == MimeTypes.Videos -> MimeTypes.Mp4
|
||||
mimeType == MimeTypes.Audio -> MimeTypes.Mp3
|
||||
else -> MimeTypes.OctetStream
|
||||
},
|
||||
// Fallback to a default mime type based on the main type, so that the SDK can create a file with the correct extension.
|
||||
mimeType = mimeType.withDefaultSubtype(),
|
||||
useCache = useCache,
|
||||
tempDir = cacheDirectory.path,
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user