Prevent the app from crashing when file mime type is null (#2582)

This commit is contained in:
Elias Nahum
2019-02-20 16:47:55 -03:00
committed by GitHub
parent c72ea6a281
commit 7df9711afa
2 changed files with 14 additions and 7 deletions

View File

@@ -165,12 +165,15 @@ public class ShareModule extends ReactContextBaseJavaModule {
map.putString("value", text);
type = RealPathUtil.getMimeTypeFromUri(currentActivity, uri);
if (type.equals("image/*")) {
type = "image/jpeg";
} else if (type.equals("video/*")) {
type = "video/mp4";
if (type != null) {
if (type.equals("image/*")) {
type = "image/jpeg";
} else if (type.equals("video/*")) {
type = "video/mp4";
}
} else {
type = "application/octet-stream";
}
map.putString("type", type);
items.pushMap(map);
}