Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
_fetchDownload = async () => {
try {
const downloadJson = await AsyncStorage.getItem('pausedDownload');
if (downloadJson !== null) {
const downloadFromStore = JSON.parse(downloadJson);
const callback: FileSystem.DownloadProgressCallback = downloadProgress => {
const progress =
downloadProgress.totalBytesWritten / downloadProgress.totalBytesExpectedToWrite;
this.setState({
downloadProgress: progress,
});
};
this.download = new FileSystem.DownloadResumable(
downloadFromStore.url,
downloadFromStore.fileUri,
downloadFromStore.options,
callback,
downloadFromStore.resumeData
);
await this.download.resumeAsync();
if (this.state.downloadProgress === 1) {
alert('Download complete!');
}
} else {
alert('Initiate a download first!');
return;
}
} catch (e) {
console.log(e);