Skip to content
Browse files

Fix Android Camera Roll crash on mime type guessing (#24780)

Fixes this issue:
It was incorrectly closed by a fix on react-native-community CameraRoll implementation. CameraRoll in react-native still crashes when finding a file with # sign

[Android] [Fix] - Fix Android Camera Roll crash on mime type guessing
Pull Request resolved: #24780

Reviewed By: mdvacca

Differential Revision: D15281062

Pulled By: lunaleaps

fbshipit-source-id: ca3364c8478d9bfc9a0a6657b531ffb384145d8c
  • Loading branch information...
Sroka authored and facebook-github-bot committed May 10, 2019
1 parent a6f905f commit ebeb893b50b4aa1ad77bdb203e4f8faed75db43a
@@ -50,7 +50,6 @@
import java.util.ArrayList;
import java.util.List;
import javax.annotation.Nullable;

// TODO #6015104: rename to something less iOSish
@@ -388,7 +387,8 @@ private static void putEdges(
WritableMap edge = new WritableNativeMap();
WritableMap node = new WritableNativeMap();
boolean imageInfoSuccess =
putImageInfo(resolver, media, node, idIndex, widthIndex, heightIndex, dataIndex);
putImageInfo(resolver, media, node, idIndex, widthIndex, heightIndex, dataIndex,
if (imageInfoSuccess) {
putBasicNodeInfo(media, node, mimeTypeIndex, groupNameIndex, dateTakenIndex);
putLocationInfo(media, node, longitudeIndex, latitudeIndex);
@@ -423,20 +423,15 @@ private static boolean putImageInfo(
int idIndex,
int widthIndex,
int heightIndex,
int dataIndex) {
int dataIndex,
int mimeTypeIndex) {
WritableMap image = new WritableNativeMap();
Uri photoUri = Uri.parse("file://" + media.getString(dataIndex));
image.putString("uri", photoUri.toString());
float width = media.getInt(widthIndex);
float height = media.getInt(heightIndex);

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;
String mimeType = media.getString(mimeTypeIndex);

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

0 comments on commit ebeb893

Please sign in to comment.
You can’t perform that action at this time.