https://github.com/joehand/dat-download
simple dat downloading module
https://github.com/joehand/dat-download
dat
Last synced: 10 months ago
JSON representation
simple dat downloading module
- Host: GitHub
- URL: https://github.com/joehand/dat-download
- Owner: joehand
- License: mit
- Created: 2017-08-25T22:36:40.000Z (over 8 years ago)
- Default Branch: master
- Last Pushed: 2023-01-11T18:45:22.000Z (about 3 years ago)
- Last Synced: 2025-04-15T17:17:11.290Z (11 months ago)
- Topics: dat
- Language: JavaScript
- Size: 165 KB
- Stars: 10
- Watchers: 2
- Forks: 4
- Open Issues: 5
-
Metadata Files:
- Readme: README.md
- License: LICENSE.md
Awesome Lists containing this project
README
# dat-download
One-time file downloads via Dat. Download a single file or subdirectory from a dat. Automatically joins the network and handles everything for you.
[![npm][npm-image]][npm-url]
[![travis][travis-image]][travis-url]
[![standard][standard-image]][standard-url]
## Example
```js
var datDownload = require('dat-download')
datDownload('dat://778f8d955175c92e4ced5e4f5563f69bfec0c86cc6f670352c457943666fe639/dat.json', process.cwd(), function (err) {
if (err) throw err
console.log('done downloading! thanks')
})
```
Works with DNS-type dat keys too!
```js
var datDownload = require('dat-download')
datDownload('dat://beakerbrowser.com/index.html', process.cwd(), function (err) {
if (err) throw err
console.log('done downloading! thanks')
})
```
Can also download a whole dat:
```js
var datDownload = require('dat-download')
datDownload('dat://beakerbrowser.com/', process.cwd(), function (err) {
if (err) throw err
console.log('done downloading! thanks')
})
```
## Install
```
npm install dat-download
```
## API
### `datDownload(datPath, [destination], callback)`
* `datPath` - dat key with subdirectory or file path. If the whole key is specified, it will download to `destination/key`.
* `destination` - download folder
## License
[MIT](LICENSE.md)
[npm-image]: https://img.shields.io/npm/v/dat-download.svg?style=flat-square
[npm-url]: https://www.npmjs.com/package/dat-download
[travis-image]: https://img.shields.io/travis/joehand/dat-download.svg?style=flat-square
[travis-url]: https://travis-ci.org/joehand/dat-download
[standard-image]: https://img.shields.io/badge/code%20style-standard-brightgreen.svg?style=flat-square
[standard-url]: http://npm.im/standard