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

.then() cant callback when plateform is IOS #237

Closed
daniel031699 opened this issue Nov 17, 2018 · 0 comments
Closed

.then() cant callback when plateform is IOS #237

daniel031699 opened this issue Nov 17, 2018 · 0 comments

Comments

@daniel031699
Copy link

daniel031699 commented Nov 17, 2018

  • the version of installed library and RN project.
    "rn-fetch-blob": "^0.10.13",
    "react-native": "0.55.4",
  • a sample code snippet/repository is very helpful to spotting the problem.
    _uploadImg(images){
    // 创建上传的请求头,使用fetch-blob必须要遵循name,data的格式,要不然就不成功。
    let body = images.map(i => {
    let PATH = Platform.OS!=='ios'?i.path.replace('file:///',''):i.path;
    return {name: 'file', filename: 'jpg', data: RNFetchBlob.wrap(PATH)};
    });
    RNFetchBlob.fetch('POST',global.httpUrl+'/files',{
    // 上传图片要设置Header
    'Content-Type' : 'multipart/form-data',
    'token': global.unionid
    },body)
    // .uploadProgress({ interval : 250 },(written, total) => {
    // // 查找进度
    // // console.log('查找进度',written/total)
    // })
    // .progress({ count : 10 },(received, total) => {
    // // 上传进度打印
    // // console.log('上传进度打印',received/total)
    // this.props.loadingProgress(received/total)
    // })
    .then((response)=> {
    this.props.addImageUrl(response.data)
    })
    .catch((error)=>{
    // 错误信息
    console.error(error);
    Alert.alert('上传失败,请重试!');
    });
    }
cguino pushed a commit to BeApp/rn-fetch-blob that referenced this issue Jul 5, 2023
…_callback_invocation

Fix bug Illegal callback invocation from native module
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant