Skip to content
This repository has been archived by the owner on Mar 16, 2019. It is now read-only.

Commit

Permalink
Catch null contentUri (#343)
Browse files Browse the repository at this point in the history
  • Loading branch information
AndrewJack authored and wkh237 committed Apr 26, 2017
1 parent 335d83d commit ecbf535
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions android/src/main/java/com/RNFetchBlob/RNFetchBlobReq.java
Original file line number Diff line number Diff line change
Expand Up @@ -641,12 +641,14 @@ public void onReceive(Context context, Intent intent) {
return;
}
String contentUri = c.getString(c.getColumnIndex(DownloadManager.COLUMN_LOCAL_URI));
Uri uri = Uri.parse(contentUri);
Cursor cursor = appCtx.getContentResolver().query(uri, new String[]{android.provider.MediaStore.Images.ImageColumns.DATA}, null, null, null);
// use default destination of DownloadManager
if (cursor != null) {
cursor.moveToFirst();
filePath = cursor.getString(0);
if (contentUri != null) {
Uri uri = Uri.parse(contentUri);
Cursor cursor = appCtx.getContentResolver().query(uri, new String[]{android.provider.MediaStore.Images.ImageColumns.DATA}, null, null, null);
// use default destination of DownloadManager
if (cursor != null) {
cursor.moveToFirst();
filePath = cursor.getString(0);
}
}
}
// When the file is not found in media content database, check if custom path exists
Expand Down

0 comments on commit ecbf535

Please sign in to comment.