应用程序的react-native-fetch-blob

时间:2019-01-02 20:37:48

标签: reactjs react-native react-redux react-native-fetch-blob

我不知道原因。但是该应用程序停止了。下载完文件后。在android设备上。

工作正常,直到完成下载

有人有什么建议吗?

export const downloadFile = (userUid, video, teacher) => {
  return (dispatch) => {



let download = '';
RNFetchBlob
.config({
  fileCache : true,
})
.fetch('GET', video.video, {
  Authorization : 'Bearer access-token...',
})
.progress((received, total) => {
    //alert('progress' + (received / total) )
  let progress = (received / total) *100
  dispatch({
    type:'progressDownload',
    payload:{
      key: video.key,
      progress: progress
    }
  });
})
// when response status code is 200
.then((res) => {
  //FIM DO CARREGAMENTO
 dispatch({
    type:'finishDownload',
    payload:{
      key: video.key,
      progress: 100,
      status: 'completed',
      locate: {
        path: res.path(),
      }
    }
  });
})
// Status code is not 200
.catch((errorMessage, statusCode) => {
  alert(errorMessage)
}) 

} }

0 个答案:

没有答案