Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 17 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,11 @@ After `0.10.3` you can install this package directly from Github
# replace <branch_name> with any one of the branches
npm install --save github:wkh237/react-native-fetch-blob-package#<branch_name>
```

**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)
Expand Down Expand Up @@ -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
})
Expand Down
2 changes: 1 addition & 1 deletion android/src/main/java/com/RNFetchBlob/RNFetchBlobFS.java
Original file line number Diff line number Diff line change
Expand Up @@ -245,7 +245,7 @@ static Map<String, Object> 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) {
Expand Down
2 changes: 1 addition & 1 deletion ios/RNFetchBlobReqBuilder.m
Original file line number Diff line number Diff line change
Expand Up @@ -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]);
Expand Down