Skip to content

Commit d9711e2

Browse files
Luna Weifacebook-github-bot
Luna Wei
authored andcommitted
Log uri for guessContentTypeFromName exceptions
Summary: Add additional logging around the exception to figure out what kind of uris are causing the exception for `getContentTypeForFileName` Reviewed By: PeteTheHeat Differential Revision: D14715917 fbshipit-source-id: 46299d2ff3f1f06991d7800784a025a85815ae8c
1 parent 15b2f99 commit d9711e2

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

ReactAndroid/src/main/java/com/facebook/react/modules/camera/CameraRollManager.java

+7-1
Original file line numberDiff line numberDiff line change
@@ -417,7 +417,13 @@ private static boolean putImageInfo(
417417
float width = media.getInt(widthIndex);
418418
float height = media.getInt(heightIndex);
419419

420-
String mimeType = URLConnection.guessContentTypeFromName(photoUri.toString());
420+
String mimeType;
421+
try {
422+
mimeType = URLConnection.guessContentTypeFromName(photoUri.toString());
423+
} catch (StringIndexOutOfBoundsException e) {
424+
FLog.e(ReactConstants.TAG, "Unable to guess content type from " + photoUri.toString(), e);
425+
throw e;
426+
}
421427

422428
if (mimeType != null
423429
&& mimeType.startsWith("video")) {

0 commit comments

Comments
 (0)