itinance / itinance/react-native-fs

stopDownload callback

Open
#828 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
C++
Stars
5k
Forks
1k
PR merge metrics
No merged PRs in 30d

Description

How can we identify if the download has been stopped? Can't see anything stated in the docs / issues here.

```
download = () => {
const path =
RNFS.DocumentDirectoryPath +
'/' +
'documents/' +
this.state.id +
'.' +
this.state.extension;

RNFS.downloadFile({
fromUrl: this.state.url,
toFile: path,
//headers
discretionary: true, // IOS ONLY - Improves performance
begin: _res => {
console.log('@download started: ', _res);
this.setState({
jobId: _res.jobId,
downloading: true,
});
},
progress: _res => {
this.setState({
progress: parseInt(
(_res.bytesWritten / _res.contentLength) * 100,
10,
),
});
},
}).promise.then(res => {
console.log('@download complete: ', res);
this.setState({
downloaded: true,
downloading: false,
progress: 100,
uri: path,
});
});
};

abort = () => {
RNFS.stopDownload(this.state.jobId);
};
```

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.