Skip to content

Commit 3261740

Browse files
author
Ron Radtke
committed
fixes #321
hopefully fixes this issue
1 parent 070ce10 commit 3261740

File tree

3 files changed

+11
-8
lines changed

3 files changed

+11
-8
lines changed

android/src/main/java/com/ReactNativeBlobUtil/ReactNativeBlobUtilReq.java

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -678,7 +678,7 @@ private void done(Response resp) {
678678
try (FileOutputStream fos = new FileOutputStream(file)) {
679679
fos.write(ReactNativeBlobUtilFileTransformer.sharedFileTransformer.onWriteFile(b));
680680
} catch (Exception e) {
681-
invoke_callback("Error from file transformer:" + e.getLocalizedMessage(), null);
681+
invoke_callback("Error from file transformer:" + e.getLocalizedMessage(), respmap.copy());
682682
return;
683683
}
684684
invoke_callback(null, ReactNativeBlobUtilConst.RNFB_RESPONSE_PATH, this.destPath, respmap.copy());
@@ -709,7 +709,7 @@ private void done(Response resp) {
709709
}
710710
}
711711
} catch (IOException e) {
712-
invoke_callback("ReactNativeBlobUtil failed to encode response data to BASE64 string.", null);
712+
invoke_callback("ReactNativeBlobUtil failed to encode response data to BASE64 string.", respmap.copy());
713713
}
714714
break;
715715
case FileStorage:
@@ -741,15 +741,15 @@ private void done(Response resp) {
741741
} catch (IOException exception) {
742742
exception.printStackTrace();
743743
}
744-
invoke_callback("Unexpected FileStorage response file: " + responseBodyString, null);
744+
invoke_callback("Unexpected FileStorage response file: " + responseBodyString, respmap.copy());
745745
} else {
746-
invoke_callback("Unexpected FileStorage response with no file.", null);
746+
invoke_callback("Unexpected FileStorage response with no file.", respmap.copy());
747747
}
748748
return;
749749
}
750750

751751
if (ReactNativeBlobUtilFileResp != null && !ReactNativeBlobUtilFileResp.isDownloadComplete()) {
752-
invoke_callback("Download interrupted.", null, respmap.copy());
752+
invoke_callback("Download interrupted.", respmap.copy());
753753
} else {
754754
this.destPath = this.destPath.replace("?append=true", "");
755755
invoke_callback(null, ReactNativeBlobUtilConst.RNFB_RESPONSE_PATH, this.destPath, respmap.copy());
@@ -760,7 +760,7 @@ private void done(Response resp) {
760760
try {
761761
invoke_callback(null, ReactNativeBlobUtilConst.RNFB_RESPONSE_UTF8, new String(resp.body().bytes(), "UTF-8"), respmap.copy());
762762
} catch (IOException e) {
763-
invoke_callback("ReactNativeBlobUtil failed to encode response data to UTF8 string.", null);
763+
invoke_callback("ReactNativeBlobUtil failed to encode response data to UTF8 string.", respmap.copy());
764764
}
765765
break;
766766
}

fetch.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -260,6 +260,8 @@ export function fetch(...args: any): Promise {
260260
promise.cancel = () => {
261261
};
262262

263+
if(!responseInfo) responseInfo = {}; // should not be null / undefined
264+
263265
if (err)
264266
reject(new Error(err, respInfo));
265267
else {
@@ -269,9 +271,10 @@ export function fetch(...args: any): Promise {
269271
if (options.session)
270272
fs.session(options.session).add(data);
271273
}
272-
respInfo.rnfbEncode = rawType;
273274
if ('uninit' in respInfo && respInfo.uninit) // event didn't fire yet so we override it here
274275
respInfo = responseInfo;
276+
277+
respInfo.rnfbEncode = rawType;
275278
resolve(new FetchBlobResponse(taskId, respInfo, data));
276279
}
277280

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "react-native-blob-util",
3-
"version": "0.19.6",
3+
"version": "0.19.8",
44
"description": "A module provides upload, download, and files access API. Supports file stream read/write for process large files.",
55
"main": "index",
66
"scripts": {

0 commit comments

Comments
 (0)