From bcd636b46e1ca173c770ff3a3d9d747f2e29c4ca Mon Sep 17 00:00:00 2001 From: David Kaspar Date: Mon, 17 Mar 2025 19:24:15 +0000 Subject: [PATCH] sniff content type from extension when empty in response --- .../com/vitorpamplona/amethyst/ui/actions/MediaSaverToDisk.kt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/actions/MediaSaverToDisk.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/actions/MediaSaverToDisk.kt index 5e7583c6f..78308d2c4 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/actions/MediaSaverToDisk.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/actions/MediaSaverToDisk.kt @@ -120,8 +120,8 @@ object MediaSaverToDisk { check(response.isSuccessful) if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q) { - val contentType = response.header("Content-Type") - checkNotNull(contentType) { "Can't find out the content type" } + val contentType = response.header("Content-Type") ?: getMimeTypeFromExtension(url) + check(contentType.isNotBlank()) { "Can't find out the content type" } val realType = if (contentType == "application/octet-stream") {