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
         }
666
         }
667
         else {
667
         else {
668
             path = normalizePath(path);
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
             if (options.addAndroidDownloads.getBoolean("useDownloadManager")) {
165
             if (options.addAndroidDownloads.getBoolean("useDownloadManager")) {
166
                 Uri uri = Uri.parse(url);
166
                 Uri uri = Uri.parse(url);
167
                 DownloadManager.Request req = new DownloadManager.Request(uri);
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
                     req.setNotificationVisibility(DownloadManager.Request.VISIBILITY_VISIBLE_NOTIFY_COMPLETED);
169
                     req.setNotificationVisibility(DownloadManager.Request.VISIBILITY_VISIBLE_NOTIFY_COMPLETED);
170
                 } else {
170
                 } else {
171
                     req.setNotificationVisibility(DownloadManager.Request.VISIBILITY_HIDDEN);
171
                     req.setNotificationVisibility(DownloadManager.Request.VISIBILITY_HIDDEN);
562
                             String utf8 = new String(b);
562
                             String utf8 = new String(b);
563
                             callback.invoke(null, RNFetchBlobConst.RNFB_RESPONSE_UTF8, utf8);
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
                         catch(CharacterCodingException ignored) {
567
                         catch(CharacterCodingException ignored) {
568
+                            
568
                             if(responseFormat == ResponseFormat.UTF8) {
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
                             else {
573
                             else {
572
                                 callback.invoke(null, RNFetchBlobConst.RNFB_RESPONSE_BASE64, android.util.Base64.encodeToString(b, Base64.NO_WRAP));
574
                                 callback.invoke(null, RNFetchBlobConst.RNFB_RESPONSE_BASE64, android.util.Base64.encodeToString(b, Base64.NO_WRAP));

+ 1
- 1
index.js View File

104
  *                   activity takes place )
104
  *                   activity takes place )
105
  *                   If it doesn't exist, the file is downloaded as usual
105
  *                   If it doesn't exist, the file is downloaded as usual
106
  *         @property {number} timeout
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
  *         @property {boolean} followRedirect
108
  *         @property {boolean} followRedirect
109
  *                   Follow redirects automatically, default true
109
  *                   Follow redirects automatically, default true
110
  *         @property {boolean} trusty
110
  *         @property {boolean} trusty