diff --git a/README.md b/README.md index 1baebfd9d..3b38b7efe 100644 --- a/README.md +++ b/README.md @@ -67,6 +67,11 @@ After `0.10.3` you can install this package directly from Github # replace with any one of the branches npm install --save github:wkh237/react-native-fetch-blob-package# ``` + +**Manually Link Native Modules** + +If automatically linking doesn't work for you, see instructions on [manually linking](https://github.com/joltup/react-native-fetch-blob/wiki/Manually-Link-Package#index). + **Automatically Link Native Modules** For 0.29.2+ projects, simply link native packages via the following command (note: rnpm has been merged into react-native) @@ -180,16 +185,20 @@ RNFetchBlob.fetch('GET', 'http://www.example.com/images/img1.png', { Authorization : 'Bearer access-token...', // more headers .. }) - // when response status code is 200 .then((res) => { - // the conversion is done in native code - let base64Str = res.base64() - // the following conversions are done in js, it's SYNC - let text = res.text() - let json = res.json() - + let status = res.info().status; + + if(status == 200) { + // the conversion is done in native code + let base64Str = res.base64() + // the following conversions are done in js, it's SYNC + let text = res.text() + let json = res.json() + } else { + // handle other status codes + } }) - // Status code is not 200 + // Something went wrong: .catch((errorMessage, statusCode) => { // error handling }) diff --git a/android/src/main/java/com/RNFetchBlob/RNFetchBlobFS.java b/android/src/main/java/com/RNFetchBlob/RNFetchBlobFS.java index 39972d066..27dfab6ae 100644 --- a/android/src/main/java/com/RNFetchBlob/RNFetchBlobFS.java +++ b/android/src/main/java/com/RNFetchBlob/RNFetchBlobFS.java @@ -245,7 +245,7 @@ static Map getSystemfolders(ReactApplicationContext ctx) { String state; state = Environment.getExternalStorageState(); if (state.equals(Environment.MEDIA_MOUNTED)) { - res.put("SDCardDir", Environment.getExternalStorageDirectory().getAbsolutePath()); + res.put("SDCardDir", Environment.getExternalStorageDirectory().getAbsolutePath() try { res.put("SDCardApplicationDir", ctx.getExternalFilesDir(null).getParentFile().getAbsolutePath()); } catch(Exception e) { diff --git a/ios/RNFetchBlobReqBuilder.m b/ios/RNFetchBlobReqBuilder.m index 16154436e..16963bb5f 100644 --- a/ios/RNFetchBlobReqBuilder.m +++ b/ios/RNFetchBlobReqBuilder.m @@ -69,7 +69,7 @@ +(void) buildMultipartRequest:(NSDictionary *)options [mheaders setValue:[NSString stringWithFormat:@"%lu",[postData length]] forKey:@"Content-Length"]; [mheaders setValue:@"100-continue" forKey:@"Expect"]; // appaned boundary to content-type - [mheaders setValue:[NSString stringWithFormat:@"multipart/form-data; charset=utf-8; boundary=%@", boundary] forKey:@"content-type"]; + [mheaders setValue:[NSString stringWithFormat:@"multipart/form-data; boundary=%@", boundary] forKey:@"content-type"]; [request setHTTPMethod: method]; [request setAllHTTPHeaderFields:mheaders]; onComplete(request, [formData length]);