Closed alereisan closed 6 years ago
Trying to download files within Nativescript Angular App
` downloadMediaFile(idx) {
// new downloader const downloader = new Downloader(); const download = Downloader.createDownload ({ url: this.fileUrl + this.mediaFiles[idx].fileName }); downloader .start(download, (progressData: ProgressEventData) => { log("Download Progress " + this.mediaFiles[idx].fileName); console.log(`Progress : ${progressData.value}%`); console.log(`Current Size : ${progressData.currentSize}%`); console.log(`Total Size : ${progressData.totalSize}%`); console.log(`Download Speed in bytes : ${progressData.speed}%`); this.mediaFiles[idx].downloadProgress = progressData.value; this.mediaFiles[idx].currentSize = progressData.currentSize; this.mediaFiles[idx].totalSize = progressData.totalSize; this.mediaFiles[idx].speed = progressData.speed; }) .then((completed: DownloadEventData) => { console.log(`Image : ${completed.path}`); log("File successfully downloaded: " + JSON.stringify(completed)); this.mediaFiles[idx].downloadProgress = 1.0; this.mediaFiles[idx].localPath = completed.path; this.timetableService.mediaFiles.next(this.mediaFiles); }) .catch(error => { console.log(error.message); // Retry this.mediaFiles[idx].downloadError = error.message; if(this.mediaFiles[idx].downloadRetries < 9) { this.mediaFiles[idx].downloadRetries++; this.downloadMediaFile(idx); } this.timetableService.mediaFiles.next(this.mediaFiles); }); }`
Which platform(s) does your issue occur on?
Please, provide the following version numbers that your issue occurs with:
Please, tell us how to recreate the issue in as much detail as possible.
Trying to download files within Nativescript Angular App
Is there any code involved?
` downloadMediaFile(idx) {