Skip to content

Commit fe4139d

Browse files
samuel-rlball-hayden
authored andcommitted
fix(android): get correct type
1 parent d817329 commit fe4139d

File tree

1 file changed

+3
-1
lines changed
  • react-native-mcu-manager/android/src/main/java/uk/co/playerdata/reactnativemcumanager

1 file changed

+3
-1
lines changed

react-native-mcu-manager/android/src/main/java/uk/co/playerdata/reactnativemcumanager/DeviceUpgrade.kt

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ import io.runtime.mcumgr.dfu.mcuboot.model.ImageSet
1515
import io.runtime.mcumgr.exception.McuMgrException
1616
import io.runtime.mcumgr.image.McuMgrImage
1717
import java.io.IOException
18+
import android.webkit.MimeTypeMap
1819

1920
val UpgradeModes =
2021
mapOf(
@@ -71,7 +72,8 @@ class DeviceUpgrade(
7172
}
7273

7374
private fun extractImagesFrom(updateBundleUri: Uri): ImageSet {
74-
val type = context.contentResolver.getType(updateBundleUri)
75+
val fileExtension = MimeTypeMap.getFileExtensionFromUrl(updateBundleUri.toString())
76+
val mimeType = MimeTypeMap.getSingleton().getMimeTypeFromExtension(fileExtension)
7577
val binData = uriToByteArray(updateBundleUri) ?: throw IOException("Failed to read update file")
7678

7779
if (type == "application/zip") {

0 commit comments

Comments
 (0)