downloadable

1.0.9 • Public • Published

downloadable

Check if url downloadable before download.

  • resolve a promise with the HTTP headers when given URL is downloadable (should have 'content-type' and 'content-length')
  • reject a promise with error message when given URL is not downloadable

NPM

Install

$ npm install --save downloadable

Test

$ npm test

Usage

    const downloadable = require("downloadable");
    const imageUrl = 'https://cdn1.iconfinder.com/data/icons/logotypes/32/square-facebook-512.png'
 
    downloadable(imageUrl).then(function(headers){
      console.log(headers['content-type'])
      console.log(headers['content-length'])
      // link is downloadable, do something ....
    },function(err){
      // link is not downloadable, do something else ....
    });
 

License

MIT

Package Sidebar

Install

npm i downloadable

Weekly Downloads

20

Version

1.0.9

License

ISC

Unpacked Size

4.69 kB

Total Files

5

Last publish

Collaborators

  • wahengchang