Browse Source

Fix Android download manager

Ben Hsieh 7 years ago
parent
commit
a7d6d77316
1 changed files with 9 additions and 2 deletions
  1. 9
    2
      src/android/src/main/java/com/RNFetchBlob/RNFetchBlobReq.java

+ 9
- 2
src/android/src/main/java/com/RNFetchBlob/RNFetchBlobReq.java View File

@@ -635,13 +635,20 @@ public class RNFetchBlobReq extends BroadcastReceiver implements Runnable {
635 635
                         boolean exists = new File(customDest).exists();
636 636
                         if(!exists)
637 637
                             throw new Exception("Download manager download failed, the file does not downloaded to destination.");
638
+                        else
639
+                            this.callback.invoke(null, RNFetchBlobConst.RNFB_RESPONSE_PATH, customDest);
638 640
 
639 641
                     } catch(Exception ex) {
640 642
                         error = ex.getLocalizedMessage();
641 643
                     }
642 644
                 }
643
-                else
644
-                    this.callback.invoke("Download manager could not resolve downloaded file path.", RNFetchBlobConst.RNFB_RESPONSE_PATH, null);
645
+                else {
646
+                    if(filePath == null)
647
+                        this.callback.invoke("Download manager could not resolve downloaded file path.", RNFetchBlobConst.RNFB_RESPONSE_PATH, null);
648
+                    else
649
+                        this.callback.invoke(null, RNFetchBlobConst.RNFB_RESPONSE_PATH, filePath);
650
+                }
651
+
645 652
             }
646 653
         }
647 654
     }