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
This commit is contained in:
Luna Wei
2019-04-02 18:35:32 -07:00
committed by Facebook Github Bot
parent 15b2f994ce
commit d9711e2693

View File

@@ -417,7 +417,13 @@ public class CameraRollManager extends ReactContextBaseJavaModule {
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")) {