Skip to content

Commit

Permalink
fixes #321
Browse files Browse the repository at this point in the history
hopefully fixes this issue
  • Loading branch information
Ron Radtke committed Feb 26, 2024
1 parent 070ce10 commit 3261740
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -678,7 +678,7 @@ private void done(Response resp) {
try (FileOutputStream fos = new FileOutputStream(file)) {
fos.write(ReactNativeBlobUtilFileTransformer.sharedFileTransformer.onWriteFile(b));
} catch (Exception e) {
invoke_callback("Error from file transformer:" + e.getLocalizedMessage(), null);
invoke_callback("Error from file transformer:" + e.getLocalizedMessage(), respmap.copy());
return;
}
invoke_callback(null, ReactNativeBlobUtilConst.RNFB_RESPONSE_PATH, this.destPath, respmap.copy());
Expand Down Expand Up @@ -709,7 +709,7 @@ private void done(Response resp) {
}
}
} catch (IOException e) {
invoke_callback("ReactNativeBlobUtil failed to encode response data to BASE64 string.", null);
invoke_callback("ReactNativeBlobUtil failed to encode response data to BASE64 string.", respmap.copy());
}
break;
case FileStorage:
Expand Down Expand Up @@ -741,15 +741,15 @@ private void done(Response resp) {
} catch (IOException exception) {
exception.printStackTrace();
}
invoke_callback("Unexpected FileStorage response file: " + responseBodyString, null);
invoke_callback("Unexpected FileStorage response file: " + responseBodyString, respmap.copy());
} else {
invoke_callback("Unexpected FileStorage response with no file.", null);
invoke_callback("Unexpected FileStorage response with no file.", respmap.copy());
}
return;
}

if (ReactNativeBlobUtilFileResp != null && !ReactNativeBlobUtilFileResp.isDownloadComplete()) {
invoke_callback("Download interrupted.", null, respmap.copy());
invoke_callback("Download interrupted.", respmap.copy());
} else {
this.destPath = this.destPath.replace("?append=true", "");
invoke_callback(null, ReactNativeBlobUtilConst.RNFB_RESPONSE_PATH, this.destPath, respmap.copy());
Expand All @@ -760,7 +760,7 @@ private void done(Response resp) {
try {
invoke_callback(null, ReactNativeBlobUtilConst.RNFB_RESPONSE_UTF8, new String(resp.body().bytes(), "UTF-8"), respmap.copy());
} catch (IOException e) {
invoke_callback("ReactNativeBlobUtil failed to encode response data to UTF8 string.", null);
invoke_callback("ReactNativeBlobUtil failed to encode response data to UTF8 string.", respmap.copy());
}
break;
}
Expand Down
5 changes: 4 additions & 1 deletion fetch.js
Original file line number Diff line number Diff line change
Expand Up @@ -260,6 +260,8 @@ export function fetch(...args: any): Promise {
promise.cancel = () => {
};

if(!responseInfo) responseInfo = {}; // should not be null / undefined

if (err)
reject(new Error(err, respInfo));
else {
Expand All @@ -269,9 +271,10 @@ export function fetch(...args: any): Promise {
if (options.session)
fs.session(options.session).add(data);
}
respInfo.rnfbEncode = rawType;
if ('uninit' in respInfo && respInfo.uninit) // event didn't fire yet so we override it here
respInfo = responseInfo;

respInfo.rnfbEncode = rawType;
resolve(new FetchBlobResponse(taskId, respInfo, data));
}

Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "react-native-blob-util",
"version": "0.19.6",
"version": "0.19.8",
"description": "A module provides upload, download, and files access API. Supports file stream read/write for process large files.",
"main": "index",
"scripts": {
Expand Down

0 comments on commit 3261740

Please sign in to comment.