Skip to content

Commit

Permalink
Fix an issue with non "image" mimeTypes downloading on android
Browse files Browse the repository at this point in the history
* The promise fails even though the download goes through due to this explicit check not setting filePath
  • Loading branch information
iJimmyWei committed Jul 6, 2020
1 parent 1933faf commit 73bfb9c
Showing 1 changed file with 2 additions and 4 deletions.
6 changes: 2 additions & 4 deletions android/src/main/java/com/RNFetchBlob/RNFetchBlobReq.java
Original file line number Diff line number Diff line change
Expand Up @@ -762,11 +762,9 @@ public void onReceive(Context context, Intent intent) {
return;
}
String contentUri = c.getString(c.getColumnIndex(DownloadManager.COLUMN_LOCAL_URI));
if ( contentUri != null &&
options.addAndroidDownloads.hasKey("mime") &&
options.addAndroidDownloads.getString("mime").contains("image")) {
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);
Cursor cursor = appCtx.getContentResolver().query(uri, new String[]{android.provider.MediaStore.Files.FileColumns.DATA}, null, null, null);
// use default destination of DownloadManager
if (cursor != null) {
cursor.moveToFirst();
Expand Down

0 comments on commit 73bfb9c

Please sign in to comment.