Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

When Ios upload image should delete charset=utf-8 in http request header content-type ,otherwise will cause bug #76

Closed
wants to merge 8 commits into from
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