Browse Source

Merge branch 'master' into wifiOnly

Travis Nuttall 4 years ago
parent
commit
3aefc4b24f
No account linked to committer's email address

+ 8
- 3
android/src/main/java/com/RNFetchBlob/RNFetchBlobFS.java View File

@@ -666,9 +666,14 @@ class RNFetchBlobFS {
666 666
         }
667 667
         else {
668 668
             path = normalizePath(path);
669
-            boolean exist = new File(path).exists();
670
-            boolean isDir = new File(path).isDirectory();
671
-            callback.invoke(exist, isDir);
669
+            if (path != null) {
670
+                boolean exist = new File(path).exists();
671
+                boolean isDir = new File(path).isDirectory();
672
+                callback.invoke(exist, isDir);
673
+            }
674
+            else {
675
+                callback.invoke(false, false);
676
+            }
672 677
         }
673 678
     }
674 679
 

+ 6
- 4
android/src/main/java/com/RNFetchBlob/RNFetchBlobReq.java View File

@@ -165,7 +165,7 @@ public class RNFetchBlobReq extends BroadcastReceiver implements Runnable {
165 165
             if (options.addAndroidDownloads.getBoolean("useDownloadManager")) {
166 166
                 Uri uri = Uri.parse(url);
167 167
                 DownloadManager.Request req = new DownloadManager.Request(uri);
168
-                if(options.addAndroidDownloads.getBoolean("notification")) {
168
+                if(options.addAndroidDownloads.hasKey("notification") && options.addAndroidDownloads.getBoolean("notification")) {
169 169
                     req.setNotificationVisibility(DownloadManager.Request.VISIBILITY_VISIBLE_NOTIFY_COMPLETED);
170 170
                 } else {
171 171
                     req.setNotificationVisibility(DownloadManager.Request.VISIBILITY_HIDDEN);
@@ -562,11 +562,13 @@ public class RNFetchBlobReq extends BroadcastReceiver implements Runnable {
562 562
                             String utf8 = new String(b);
563 563
                             callback.invoke(null, RNFetchBlobConst.RNFB_RESPONSE_UTF8, utf8);
564 564
                         }
565
-                        // This usually mean the data is contains invalid unicode characters, it's
566
-                        // binary data
565
+                        // This usually mean the data is contains invalid unicode characters but still valid data,
566
+                        // it's binary data, so send it as a normal string
567 567
                         catch(CharacterCodingException ignored) {
568
+                            
568 569
                             if(responseFormat == ResponseFormat.UTF8) {
569
-                                callback.invoke(null, RNFetchBlobConst.RNFB_RESPONSE_UTF8, "");
570
+                                String utf8 = new String(b);
571
+                                callback.invoke(null, RNFetchBlobConst.RNFB_RESPONSE_UTF8, utf8);
570 572
                             }
571 573
                             else {
572 574
                                 callback.invoke(null, RNFetchBlobConst.RNFB_RESPONSE_BASE64, android.util.Base64.encodeToString(b, Base64.NO_WRAP));

+ 1
- 1
index.js View File

@@ -104,7 +104,7 @@ function wrap(path:string):string {
104 104
  *                   activity takes place )
105 105
  *                   If it doesn't exist, the file is downloaded as usual
106 106
  *         @property {number} timeout
107
- *                   Request timeout in millionseconds, by default it's 30000ms.
107
+ *                   Request timeout in millionseconds, by default it's 60000ms.
108 108
  *         @property {boolean} followRedirect
109 109
  *                   Follow redirects automatically, default true
110 110
  *         @property {boolean} trusty