|
@@ -629,10 +629,17 @@ public class RNFetchBlobReq extends BroadcastReceiver implements Runnable {
|
629
|
629
|
DownloadManager dm = (DownloadManager) appCtx.getSystemService(Context.DOWNLOAD_SERVICE);
|
630
|
630
|
dm.query(query);
|
631
|
631
|
Cursor c = dm.query(query);
|
632
|
|
- String error = null;
|
|
632
|
+
|
|
633
|
+
|
633
|
634
|
String filePath = null;
|
634
|
635
|
// the file exists in media content database
|
635
|
636
|
if (c.moveToFirst()) {
|
|
637
|
+ // #297 handle failed request
|
|
638
|
+ int statusCode = c.getInt(c.getColumnIndex(DownloadManager.COLUMN_STATUS));
|
|
639
|
+ if(statusCode == DownloadManager.STATUS_FAILED) {
|
|
640
|
+ this.callback.invoke("Download manager failed to download from " + this.url + ". Statu Code = " + statusCode, null, null);
|
|
641
|
+ return;
|
|
642
|
+ }
|
636
|
643
|
String contentUri = c.getString(c.getColumnIndex(DownloadManager.COLUMN_LOCAL_URI));
|
637
|
644
|
Uri uri = Uri.parse(contentUri);
|
638
|
645
|
Cursor cursor = appCtx.getContentResolver().query(uri, new String[]{android.provider.MediaStore.Images.ImageColumns.DATA}, null, null, null);
|
|
@@ -653,7 +660,8 @@ public class RNFetchBlobReq extends BroadcastReceiver implements Runnable {
|
653
|
660
|
this.callback.invoke(null, RNFetchBlobConst.RNFB_RESPONSE_PATH, customDest);
|
654
|
661
|
|
655
|
662
|
} catch(Exception ex) {
|
656
|
|
- error = ex.getLocalizedMessage();
|
|
663
|
+ ex.printStackTrace();
|
|
664
|
+ this.callback.invoke(ex.getLocalizedMessage(), null);
|
657
|
665
|
}
|
658
|
666
|
}
|
659
|
667
|
else {
|