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 🙏

© 2026 – Pkg Stats / Ryan Hefner

cordova-plugin-document-contract

v0.4.1

Published

Cordova plugin to interact with an Android Document Provider.

Readme

cordova-plugin-document-contract

Android document / media provider plugin for Cordova

Installation

Install through the Cordova plugin repository:

cordova plugin add cordova-plugin-document-contract

Install directly from github:

cordova plugin add https://github.com/danjarvis/cordova-plugin-document-contract.git

Methods

The plugin exposes two functions for working with a document/media provider.

getContract({
    uri: 'content://com.foo.bar/xyz',  // content URI (required)
    columns: ['_display_name']         // projection of columns (optional)
  },
  success,                             // success callback
  error);                              // error callback

Resolves a content URI and retrieves a contract object.

An object of key/value pairs will get passed to the success callback (keys will becolumns that returned a value).

If columns is not specified, the query will return all available columns. This is not recommended as it is inefficient.

Documentation for columns of interest:

createFile({
    uri: 'content://com.foo.bar/xyz'	// content URI (required)
    fileName: 'file.pdf'                // name of output file (required)
  },
  success,                              // success callback
  error);                               // error callback

Resolves a content URI, retrieves corresponding file data and writes it to a file in the application's data directory (cordova.file.dataDirectory).

Usage

For the below examples, assume that

  1. contentUri is valid Content URI (e.g. coming from a Google Drive Send Intent).
  2. The Cordova File Plugin plugin is installed.

Get a full contract:

window.plugins.DocumentContract.getContract({
    uri: contentUri
  },
  function(contract) {
    console.dir(contract);
    // Outputs
    // {
    //   '_display_name': 'SampleFile.pdf',
    //   'document_id': 'foo123',
    //   'last_modified': '/SomeDate/',
    //   'mime_type': 'application/pdf',
    //   'nth key': 'nth value'
    // }
  },
  function(error) {
    console.log('Error getting contract: ' + error);
  }
);

Get a specific contract:

window.plugins.DocumentContract.getContract({
    uri: contentUri,
    columns: [
      '_display_name', 'mime_type', '_size'
    ]
  },
  function(contract) {
    console.dir(contract);
    // Outputs
    // {
    //   '_display_name': 'SampleFile.pdf',
    //   '_size': '5242880',
    //   'mime_type': 'application/pdf'
    // }
  },
  function(error) {
    console.log('Error getting contract: ' + error);
  }
);

Get file name and create file:

window.plugins.DocumentContract.getContract({
    uri: contentUri,
      columns: [
      '_display_name'
    ]
  },
  function(contract) {
    window.plugins.DocumentContract.createFile({
        uri: contentUri,
        fileName: contract['_display_name'] || 'unknown'
      },
      function(fileName) {
        resolveLocalFileSystemURL(
          cordova.file.dataDirectory + fileName,
          function(fileEntry) {
            // Do something with FileEntry
          },
          function(error) {
            console.log('Error resolving file: ' + error);
          }
        );
      },
      function(error) {
        console.log('Error creating file: ' + error);
      }
    );
  },
  function(error) {
    console.log('Error getting contract: ' + error);
  }
);

License

© Dan Jarvis 2015, MIT