npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

cordova-plugin-file-downloader

v0.4.0

Published

Downloads files to persistant Storage on your Phone, checks md5sum if you want, unzips packed files if necessary (For Android and iOS)

Downloads

268

Readme

file-downloader

Cordova plugin to download a List of files or a single file to the Phone, check consistency and unzip if necessary (Android and ios)

install

cordova plugin add cordova-plugin-file-downloader

usage

Initialize the downloader

downloader.init({folder: "yourPersistantAppFolder", unzip: true});

options:

  • folder: folder to store downloads in [required]
  • fileSystem: fileSystem to store downloads in (use cordova.file.* to be platform independent)
  • unzip: true -> unzip after download is enabled [default: false]
  • check: true -> md5sum of file is checked after download [default: false]
  • delete: true -> delete after unpack a zipfile [default: true]
  • noMedia: true -> prevent gallery from scan files on android [default: true]
  • wifiOnly: true -> only Download when connected to Wifi, else fires DOWNLOADER_noWifiConnection event [default: false]

Download single file

downloader.get("http://yourhost.de/some.zip");

Download multiple files

downloader.getMultipleFiles([
  {url:"http://yourhost.de/some1.zip"},
  {url:"http://yourhost.de/some2.zip"},
  {url:"http://yourhost.de/some3.zip"}
]);

Abort download in progress

You have to re-init downloader after aborting an transfer

downloader.abort();

Events

document.addEventListener(eventName, function(event){
  var data = event.data;
});

eventNames:
DOWNLOADER_initialized        data:none
DOWNLOADER_gotFileSystem      data:[cordova.fileSystem fileSystem]
DOWNLOADER_gotFolder          data:[cordova.fileEntry folder]
DOWNLOADER_error              data:[object error]
DOWNLOADER_noWifiConnection   data:none
DOWNLOADER_downloadSuccess    data:[cordova.fileEntry entry]
DOWNLOADER_downloadError      data:[object error]
DOWNLOADER_downloadProgress   data:[number percentage, string fileName]
DOWNLOADER_unzipSuccess       data:[string fileName]
DOWNLOADER_unzipError         data:[string fileName]
DOWNLOADER_unzipProgress      data:[number percentage, string fileName]
DOWNLOADER_fileRemoved        data:[cordova.fileEntry entry]
DOWNLOADER_fileRemoveError    data:[cordova.fileEntry entry]
DOWNLOADER_getFileError       data:[object error]
DOWNLOADER_fileCheckSuccess   data:[string md5sum, string fileName]
DOWNLOADER_fileCheckFailed    data:[string calculatedMd5sum, string md5, string fileName])
DOWNLOADER_fileCheckError     data:[object error]

Full Examples

Download file some.txt to folder testApp

downloader.init({folder: "testApp"});
downloader.get("http://yourhost.de/some.txt");

Download file some.txt to folder testApp and give it a new name

downloader.init({folder: "testApp"});
downloader.get("http://yourhost.de/some.txt", null, "ohername.txt");

Download file some.zip to testApp, extract it and delete it afterwards

downloader.init({folder: "testApp", unzip: true});
downloader.get("http://yourhost.de/some.zip");

Download file some.zip to testApp, extract it and don't delete it afterwards

downloader.init({folder: "testApp", unzip: true, delete: false});
downloader.get("http://yourhost.de/some.zip");

Download file some.zip to testApp, check if md5sum matches given string and extract it and delete it afterwards

downloader.init({folder: "testApp", unzip: true, check: true});
downloader.get("http://yourhost.de/some.zip", "3f4ea2219aa321ef5cd3143ea33076ab");

Download file abort.zip and abort download, the download another.zip

downloader.init({folder: "testApp", unzip: true, check: true});
downloader.get("http://yourhost.de/abort.zip");
downloader.abort();
downloader.init({folder: "testApp", unzip: true, check: true});
downloader.get("http://yourhost.de/another.zip");

Download multiple zip-files to testApp, check if md5sum matches given string and extract it and delete it afterwards

downloader.init({folder: "testApp", unzip: true, check: true});
downloader.getMultipleFiles([
  {url: "http://yourhost.de/some1.zip", md5:"1f4ea2219aa321ef5cd3143ea33076ac"},
  {url: "http://yourhost.de/some2.zip", md5:"2f4ea2219aa321ef5cd3143ea33076ad"},
  {url: "http://yourhost.de/some3.zip", md5:"3f4ea2219aa321ef5cd3143ea33076ae"}
]);