# cordova-plugin-downloadmanager **Repository Path**: xiaoxiongApp/cordova-plugin-downloadmanager ## Basic Information - **Project Name**: cordova-plugin-downloadmanager - **Description**: No description available - **Primary Language**: Unknown - **License**: ISC - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 0 - **Created**: 2020-04-01 - **Last Updated**: 2020-12-19 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README # `cordova-plugin-android-downloadmanager` [![Build Status](https://travis-ci.org/emilbayes/cordova-plugin-android-downloadmanager.svg?branch=master)](https://travis-ci.org/emilbayes/cordova-plugin-android-downloadmanager) > Plugin to expose Android's DownloadManager in Javascript ## Usage ```js var downloadManager = require('cordova-plugin-android-downloadmanager.DownloadManager') ``` ## API Please refer to [`DownloadManager`](https://developer.android.com/reference/android/app/DownloadManager.html) for parameter use. ### `downloadManager.enqueue(req, [cb])` `cb(err, idString)` ``` { uri: '', title: '', description: '', mimeType: '', visibleInDownloadsUi: true, notificationVisibility: 0,//0 下载完成后从通知栏消失,1 下载后通知不消失 ,2 不显示通知栏 // Either of the next three properties destinationInExternalFilesDir: { dirType: '', subPath: '' }, destinationInExternalPublicDir: { dirType: '', subPath: '' }, destinationUri: '', headers: [{header: 'Authorization', value: 'Bearer iaksjfd89aklfdlkasdjf'}] } ``` ### `downloadManager.query([filter], cb)` You can query the SQLite database that backs DownloadManager, but the native Android `query` method only supports two filters: ``` { ids: ["1"], status: 0 } ``` This will invoke the callback of the signature `cb(err, entryArray)` with each `entry` being objects of the form: ```js { "id": String, "title": String, "description": String, "mediaType": String, "localFilename": String, "localUri": String, "mediaproviderUri": String, "uri": String, "lastModifiedTimestamp": Number, "status": Number,// 失败16,暂停4,准备中1,下载中2,成功8 "reason": Number, "bytesDownloadedSoFar": Number,//已下载的大小 "totalSizeBytes": Number//总大小 } ``` ### `downloadManager.remove(ids, [cb])` `ids` should be an array of string id's. `cb(err, removedCount)` ### `downloadManager.addCompletedDownload(req, [cb])` `cb(err, idString)` ``` { title: '', description: '', isMediaScannerScannable: false, mimeType: '', path: '', length: 0, showNotification: true } ``` Note: Don't include any `file://` prefix in the path. ## Install ```sh npm install cordova-plugin-android-downloadmanager ``` ## License [ISC](LICENSE)