1.7.0 • Published 3 years ago

nativescript-download-progress v1.7.0

Weekly downloads
29
License
Apache-2.0
Repository
github
Last release
3 years ago

nativescript-download-progress apple android

npm version

Introduction

This plugin allows you to download large files and provides progress updates.

Nativescripts http.getFile method stores the data in memory which can cause out of memory exceptions and doesn't provide progress updates.

Installation

tns plugin add nativescript-download-progress

Examples

import { DownloadProgress } from "nativescript-download-progress"

const dp = new DownloadProgress();
dp.setProgressCallback((progress, url, destination) => {
    console.log('Progress:', progress, 'URL:', url, 'Destination', destination);
})
dp.downloadFile("http://ipv4.download.thinkbroadband.com/20MB.zip").then(file => {
    console.log("Success", file);
}).catch(error => {
    console.log("Error", error);
})

Passing request headers

import { DownloadProgress } from "nativescript-download-progress"

const dp = new DownloadProgress();
dp.setProgressCallback((progress, url, destination) => {
    console.log('Progress:', progress, 'URL:', url, 'Destination', destination);
})
const url = "http://ipv4.download.thinkbroadband.com/20MB.zip";
const destinationPath = "some/path/to/file.zip";
const requestOptions: RequestOptions = {
    method: "GET",
    headers: {
       Authorization: "Bearer token",
    }
};
dp.downloadFile(url, requestOptions, destinationPath).then(file => {
    console.log("Success", file);
}).catch(error => {
    console.log("Error", error);
})

Async / Await

import { DownloadProgress } from "nativescript-download-progress"

const dp = new DownloadProgress();
dp.setProgressCallback((progress, url, destination) => {
    console.log('Progress:', progress, 'URL:', url, 'Destination', destination);
})
try {
    const f = await downloadFile("http://ipv4.download.thinkbroadband.com/20MB.zip");
} catch(e) {
    console.log("Error", error);
}

License

Apache License Version 2.0, January 2004

1.7.0

3 years ago

1.5.2

3 years ago

1.6.0

3 years ago

1.5.1

3 years ago

1.5.0

3 years ago

1.4.3

4 years ago

1.4.2

4 years ago

1.4.2-rc1

4 years ago

1.4.1

4 years ago

1.4.0

4 years ago

1.3.0

4 years ago

1.2.0

5 years ago

1.1.0

6 years ago

1.0.9

6 years ago

1.0.8

6 years ago

1.0.7

6 years ago

1.0.6

6 years ago

1.0.5

6 years ago

1.0.4

6 years ago

1.0.3

6 years ago

1.0.2

6 years ago

1.0.1

6 years ago

1.0.0

6 years ago