开发者社区> 镜像站> NPM> cordova-plugin-android-downloadmanager
cordova-plugin-android-downloadmanager
Plugin to expose Android's DownloadManager in Javascript
Last updated a year ago by emilbayes .
ISC · Repository · Bugs · Original npm · Tarball · package.json
$ cnpm install cordova-plugin-android-downloadmanager 
SYNC missed versions from official npm registry.

cordova-plugin-android-downloadmanager

Build Status

Plugin to expose Android's DownloadManager in Javascript

Usage

var downloadManager = require('cordova-plugin-android-downloadmanager.DownloadManager')

API

Please refer to DownloadManager for parameter use.

downloadManager.enqueue(req, [cb])

cb(err, idString)

{
  uri: '',
  title: '',
  description: '',
  mimeType: '',

  visibleInDownloadsUi: true,
  notificationVisibility: 0,

  // 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:

{
  "id": String,
  "title": String,
  "description": String,
  "mediaType": String,
  "localFilename": String,
  "localUri": String,
  "mediaproviderUri": String,
  "uri": String,
  "lastModifiedTimestamp": Number,
  "status": Number,
  "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

npm install cordova-plugin-android-downloadmanager

License

ISC

Current Tags

  • 1.0.0                                ...           latest (a year ago)

11 Versions

  • 1.0.0                                ...           a year ago
  • 0.5.0                                ...           3 years ago
  • 0.4.0                                ...           3 years ago
  • 0.3.4                                ...           3 years ago
  • 0.3.3                                ...           3 years ago
  • 0.3.2                                ...           3 years ago
  • 0.3.1                                ...           3 years ago
  • 0.3.0                                ...           3 years ago
  • 0.2.2                                ...           3 years ago
  • 0.2.1                                ...           3 years ago
  • 0.2.0                                ...           3 years ago
Maintainers (1)
Downloads
Today 0
This Week 1
This Month 1
Last Day 0
Last Week 1
Last Month 2
Dependencies (1)
Dev Dependencies (1)
Dependents (0)
None