Bladeren bron

Fix Android download manager

Ben Hsieh 8 jaren geleden
bovenliggende
commit
a7d6d77316
1 gewijzigde bestanden met toevoegingen van 9 en 2 verwijderingen
  1. 9
    2
      src/android/src/main/java/com/RNFetchBlob/RNFetchBlobReq.java

+ 9
- 2
src/android/src/main/java/com/RNFetchBlob/RNFetchBlobReq.java Bestand weergeven

@@ -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
     }