Skip to content
This repository has been archived by the owner on Mar 10, 2020. It is now read-only.

Commit

Permalink
Add ipfs.files.add example.
Browse files Browse the repository at this point in the history
  • Loading branch information
hackergrrl committed May 23, 2016
1 parent 60ed975 commit a298bd0
Showing 1 changed file with 27 additions and 0 deletions.
27 changes: 27 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,33 @@ an array of [DAGNode][]s.

If no `callback` is passed, a promise is returned.

```js
// array in => array out
var files = [
{
path: '/tmp/myfile.txt',
stream: fs.createReadStream('/tmp/myfile.txt')
}
]
ipfs.files.add(files, function (err, dagNodes) {
// 'res' will be an array of DAGNodes
})
```

```js
// no input => duplex stream out
ipfs.files.add(function (err, stream) {
stream.on('data', function (dagNode) {
// ...
})

stream.write({path: <path to file>, stream: <readable stream>})
// write as many as you want

stream.end()
})
```




Expand Down

0 comments on commit a298bd0

Please sign in to comment.