itinance / itinance/react-native-fs
RNFS.downloadFile { [Error: Download has been aborted] framesToPop: 1, code: 'EUNSPECIFIED' }
- Dominant language
- C++
- Stars
- 5k
- Forks
- 1k
- PR merge metrics
- No merged PRs in 30d
Description
### Error Information
09-28 01:15:04.866 23067 23171 I ReactNativeJS: '======已中止下载=====', { [Error: Download has been aborted] framesToPop: 1, code: 'EUNSPECIFIED' }
### Environment
react-native-fs: v2.5.2
react-native-cli: v2.0.1
react-native: v0.48.3
node: v7.3.0
npm: 3.10.10
android: 7.0
Mobile phone networking: 4G LTE
### run downloadFile code
```
// download file
onDownLoadFile = async (sourceFilePath, cacheFilePath) => {
let options = {
fromUrl: sourceFilePath,
toFile: cacheFilePath,
background: true,
begin: this.imageDownloadBegin,
progress: this.imageDownloadProgress
};
this.setState({
downloading: true,
});
try {
// start download
let res = await RNFS.downloadFile(options).promise;
// download result
if (res && res.hasOwnProperty('statusCode')) {
switch (res.statusCode) {
case 200:
this.setState({
cachedImagePath: 'file://' + cacheFilePath,
downloading: false,
jobId: null
});
break;
default:
this.setState({
cachedImagePath: null,
downloading: false,
jobId: null
});
break;
}
}
} catch (error) {
console.log('======已中止下载=====', error);
// 删除文件
this.onDeleteFile(cacheFilePath);
// 停止下载
this.onStopDownload();
}
}
imageDownloadBegin = (info) => {
switch (info.statusCode) {
case 200:
this.setState({
downloading: true,
jobId: info.jobId
});
break;
default:
break;
}
}
imageDownloadProgress = (info) => {
this.setState({
percent: info.bytesWritten / info.contentLength * 100,
});
}
```
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.