From d9711e269355c9284d398e5ec6993cfbbcafe0e2 Mon Sep 17 00:00:00 2001 From: Luna Wei Date: Tue, 2 Apr 2019 18:35:32 -0700 Subject: [PATCH] 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 --- .../facebook/react/modules/camera/CameraRollManager.java | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/ReactAndroid/src/main/java/com/facebook/react/modules/camera/CameraRollManager.java b/ReactAndroid/src/main/java/com/facebook/react/modules/camera/CameraRollManager.java index ceb838df72b430..73a7f4ae88f6f1 100644 --- a/ReactAndroid/src/main/java/com/facebook/react/modules/camera/CameraRollManager.java +++ b/ReactAndroid/src/main/java/com/facebook/react/modules/camera/CameraRollManager.java @@ -417,7 +417,13 @@ private static boolean putImageInfo( float width = media.getInt(widthIndex); float height = media.getInt(heightIndex); - String mimeType = URLConnection.guessContentTypeFromName(photoUri.toString()); + String mimeType; + try { + mimeType = URLConnection.guessContentTypeFromName(photoUri.toString()); + } catch (StringIndexOutOfBoundsException e) { + FLog.e(ReactConstants.TAG, "Unable to guess content type from " + photoUri.toString(), e); + throw e; + } if (mimeType != null && mimeType.startsWith("video")) {