1 Star 0 Fork 0

huatech2016 / cordova-plugin-fastrde-downloader

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
贡献代码
同步代码
取消
提示: 由于 Git 不支持空文件夾,创建文件夹后会生成空的 .keep 文件
Loading...
README
MIT

phonegap-downloader

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

Changes 0.2.0 -> 0.2.1

  • Added downloader.abort() function to abort downloads in progress.

Changes 0.1.5 -> 0.2.0

  • move to new cordova plugin registry

Changes 0.1.4 -> 0.1.5

  • Fix for issue #2 new initialization after download-error works properly now.

Changes 0.1.3 -> 0.1.4

  • fixed an issue with older javascript versions and reserved words.

Changes 0.1.2 -> 0.1.3

  • Unzipping is now queue based like the download porgress.

Changes 0.1.1 -> 0.1.2

  • noMedia flag in init options to prevent gallery from scanning download folder

install

yourAppDir$ phonegap plugin add https://github.com/fastrde/phonegap-downloader.git

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.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"}
]);
The MIT License (MIT) Copyright (c) 2015 Fabian Strachanski Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

简介

Phonegap plugin to download a list of files or a single file to the phone, check consistency and unzip if necessary (Android and ios) 展开 收起
JavaScript
MIT
取消

发行版

暂无发行版

贡献者

全部

近期动态

加载更多
不能加载更多了
JavaScript
1
https://gitee.com/huatech2016/cordova-plugin-fastrde-downloader.git
git@gitee.com:huatech2016/cordova-plugin-fastrde-downloader.git
huatech2016
cordova-plugin-fastrde-downloader
cordova-plugin-fastrde-downloader
master

搜索帮助