# downploader

> A small library providing utility methods for download and upload files through http(s)

Latest version **0.1.2** (published 2017-02-05) · MIT license · 0 weekly downloads

## Install

```sh
npm install downploader
pnpm add downploader
yarn add downploader
bun add downploader
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.1.2 |
| Published | 2017-02-05 |
| First published | 2017-02-05 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 1 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Author | Lenin Alevski |
| Maintainers | alevsk |
| Keywords | http, https, files, upload, download |

## Links

- npm: https://www.npmjs.com/package/downploader
- Repository: https://github.com/alevsk/downploader
- Homepage: https://github.com/alevsk/downploader#readme
- Issues: https://github.com/alevsk/downploader/issues
- npm.io page: https://npm.io/package/downploader

## Dependencies (1)

- [random-ua](https://npm.io/package/random-ua.md) 0.0.6

## Alternatives

- [unionfs](https://npm.io/package/unionfs.md) — 2.2M weekly downloads
- [path-starts-with](https://npm.io/package/path-starts-with.md) — 35.9K weekly downloads
- [redzip](https://npm.io/package/redzip.md) — 1.2K weekly downloads
- [vscode-anymatch](https://npm.io/package/vscode-anymatch.md) — 848 weekly downloads
- [@ledgerhq/coin-filecoin](https://npm.io/package/@ledgerhq/coin-filecoin.md) — 793 weekly downloads

## Recent versions

- 0.1.2 (latest) — 2017-02-05
- 0.1.1 — 2017-02-05
- 0.1.0 — 2017-02-05

## README

DownPloader
=========

A small nodejs library providing utility methods for download and upload files through http(s)

## Installation

```
  npm install --save downploader
```

## Usage examples

#### Download

```
  var fs = require('fs');
  var dp = require('downploader');
  var download = dp.download;

  download("https://website.com/image.jpg", (err, data) => {
      if(!err) {
          fs.writeFileSync('image.jpg', data.read());
      }
  });
```

#### Upload

```
  var fs = require('fs');
  var Stream = require('stream').Transform;
  var dp = require('downploader');
  var upload = dp.upload;

  var file = "image.jpg";
  var readStream = fs.createReadStream(file);
  var bytes = new Stream();

  readStream.on('data', function (chunk) {
      bytes.push(chunk);
  });

  readStream.on('error', function (err) {
      console.log(err);
  });

  readStream.on('end', function () {
      upload(bytes, "http://localhost/", (err, data) => {
          if(err) {
            console.log(err);
          } else {
            console.log(data.read())
          }
      });
  });
```

## Tests

```
  $ while true; do { echo -e 'HTTP/1.1 200 OK\r\n'; } | sudo nc -l 80; done // start a simple http server for test upload
  $ npm test
```

## Contributing

In lieu of a formal styleguide, take care to maintain the existing coding style.
Add unit tests for any new or changed functionality. Lint and test your code.

## Release History

* 0.1.0 Initial release

---
_Source: https://npm.io/package/downploader · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
