Skip to content

Commit

Permalink
[TIMOB-25849] Obtain mime-type from content provider
Browse files Browse the repository at this point in the history
  • Loading branch information
Gary Mathews committed Mar 8, 2018
1 parent 2d6c7f8 commit dc92d4b
Showing 1 changed file with 11 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1113,6 +1113,13 @@ protected static KrollDict createDictForImage(String path)
{
String[] parts = { path };
TiBlob imageData;
String mimeType = null;

// attempt to obtain mime-type from content provider
if (path.startsWith("content://")) {
mimeType = TiApplication.getInstance().getContentResolver().getType(Uri.parse(path));
}

// Workaround for TIMOB-19910. Image is in the Google Photos cloud and not on device.
if (path.startsWith("content://com.google.android.apps.photos.contentprovider")) {
ParcelFileDescriptor parcelFileDescriptor;
Expand All @@ -1125,14 +1132,14 @@ protected static KrollDict createDictForImage(String path)
parcelFileDescriptor.close();
imageData = TiBlob.blobFromImage(image);
} catch (FileNotFoundException e) {
imageData = createImageData(parts, MIME_IMAGE);
imageData = createImageData(parts, mimeType);
} catch (IOException e) {
imageData = createImageData(parts, MIME_IMAGE);
imageData = createImageData(parts, mimeType);
}
} else {
imageData = createImageData(parts, MIME_IMAGE);
imageData = createImageData(parts, mimeType);
}
return createDictForImage(imageData, MIME_IMAGE);
return createDictForImage(imageData, mimeType);
}

public static TiBlob createImageData(String[] parts, String mimeType)
Expand Down

0 comments on commit dc92d4b

Please sign in to comment.