diff --git a/android/src/main/java/com/ReactNativeBlobUtil/ReactNativeBlobUtilReq.java b/android/src/main/java/com/ReactNativeBlobUtil/ReactNativeBlobUtilReq.java index 709814fd..296ff6c0 100644 --- a/android/src/main/java/com/ReactNativeBlobUtil/ReactNativeBlobUtilReq.java +++ b/android/src/main/java/com/ReactNativeBlobUtil/ReactNativeBlobUtilReq.java @@ -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()); @@ -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: @@ -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()); @@ -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; } diff --git a/fetch.js b/fetch.js index ed4e67f1..4f52ad37 100644 --- a/fetch.js +++ b/fetch.js @@ -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 { @@ -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)); } diff --git a/package.json b/package.json index d8cf15f9..b2b5c4d6 100644 --- a/package.json +++ b/package.json @@ -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": {