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

Commit a298bd0

Browse files
committed
Add ipfs.files.add example.
1 parent 60ed975 commit a298bd0

File tree

1 file changed

+27
-0
lines changed

1 file changed

+27
-0
lines changed

README.md

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,33 @@ an array of [DAGNode][]s.
9292

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

95+
```js
96+
// array in => array out
97+
var files = [
98+
{
99+
path: '/tmp/myfile.txt',
100+
stream: fs.createReadStream('/tmp/myfile.txt')
101+
}
102+
]
103+
ipfs.files.add(files, function (err, dagNodes) {
104+
// 'res' will be an array of DAGNodes
105+
})
106+
```
107+
108+
```js
109+
// no input => duplex stream out
110+
ipfs.files.add(function (err, stream) {
111+
stream.on('data', function (dagNode) {
112+
// ...
113+
})
114+
115+
stream.write({path: <path to file>, stream: <readable stream>})
116+
// write as many as you want
117+
118+
stream.end()
119+
})
120+
```
121+
95122

96123

97124

0 commit comments

Comments
 (0)