Skip to content

Commit 3aefc4b

Browse files
authored
Merge branch 'master' into wifiOnly
2 parents f2ac3e0 + 577556d commit 3aefc4b

File tree

3 files changed

+15
-8
lines changed

3 files changed

+15
-8
lines changed

android/src/main/java/com/RNFetchBlob/RNFetchBlobFS.java

+8-3
Original file line numberDiff line numberDiff line change
@@ -666,9 +666,14 @@ static void exists(String path, Callback callback) {
666666
}
667667
else {
668668
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+
}
672677
}
673678
}
674679

android/src/main/java/com/RNFetchBlob/RNFetchBlobReq.java

+6-4
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,7 @@ public void run() {
165165
if (options.addAndroidDownloads.getBoolean("useDownloadManager")) {
166166
Uri uri = Uri.parse(url);
167167
DownloadManager.Request req = new DownloadManager.Request(uri);
168-
if(options.addAndroidDownloads.getBoolean("notification")) {
168+
if(options.addAndroidDownloads.hasKey("notification") && options.addAndroidDownloads.getBoolean("notification")) {
169169
req.setNotificationVisibility(DownloadManager.Request.VISIBILITY_VISIBLE_NOTIFY_COMPLETED);
170170
} else {
171171
req.setNotificationVisibility(DownloadManager.Request.VISIBILITY_HIDDEN);
@@ -562,11 +562,13 @@ private void done(Response resp) {
562562
String utf8 = new String(b);
563563
callback.invoke(null, RNFetchBlobConst.RNFB_RESPONSE_UTF8, utf8);
564564
}
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
567567
catch(CharacterCodingException ignored) {
568+
568569
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);
570572
}
571573
else {
572574
callback.invoke(null, RNFetchBlobConst.RNFB_RESPONSE_BASE64, android.util.Base64.encodeToString(b, Base64.NO_WRAP));

index.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ function wrap(path:string):string {
104104
* activity takes place )
105105
* If it doesn't exist, the file is downloaded as usual
106106
* @property {number} timeout
107-
* Request timeout in millionseconds, by default it's 30000ms.
107+
* Request timeout in millionseconds, by default it's 60000ms.
108108
* @property {boolean} followRedirect
109109
* Follow redirects automatically, default true
110110
* @property {boolean} trusty

0 commit comments

Comments
 (0)