triniwiz / nativescript-downloader

Apache License 2.0
32 stars 18 forks source link

ERROR TypeError: nativescript_downloader_1.Downloader.createDownload is not a function #24

Closed alereisan closed 6 years ago

alereisan commented 6 years ago

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) {

    // 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);
    });
}`