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

Commit e35b4a2

Browse files
committed
Adds API for ipfs.files.get.
1 parent 54ff44c commit e35b4a2

File tree

1 file changed

+37
-1
lines changed

1 file changed

+37
-1
lines changed

README.md

+37-1
Original file line numberDiff line numberDiff line change
@@ -57,9 +57,44 @@ A valid (read: that follows this interface) IPFS core implementation, must expos
5757

5858
## Files
5959

60+
### `get`
61+
62+
> Get [UnixFS][] files from IPFS.
63+
64+
##### `Go` **WIP**
65+
66+
##### `JavaScript` - ipfs.files.get(hash, [callback])
67+
68+
Where `hash` is an IPFS multiaddress or multihash.
69+
70+
`callback` must follow `function (err, stream) {}` signature, where `err` is an
71+
error if the operation was not successful. `stream` will be a Readable stream,
72+
outputting objects of the form
73+
74+
```js
75+
{
76+
path: '/tmp/myfile.txt',
77+
content: Readable stream
78+
}
79+
```
80+
81+
If no `callback` is passed, a promise is returned with the Readable stream.
82+
83+
Example:
84+
85+
```js
86+
ipfs.files.get('QmQ2r6iMNpky5f1m4cnm3Yqw8VSvjuKpTcK1X7dBR1LkJF', function (err, stream) {
87+
stream.on('data', (file) => {
88+
console.log(file.path)
89+
file.content.pipe(process.stdout)
90+
})
91+
})
92+
```
93+
94+
6095
### `add`
6196

62-
> Add files and data to IPFS.
97+
> Add [UnixFS][] files and data to IPFS.
6398
6499
##### `Go` **WIP**
65100

@@ -433,3 +468,4 @@ If no `callback` is passed, a [promise][] is returned.
433468
[DAGNode]: https://github.com/vijayee/js-ipfs-merkle-dag
434469
[multihash]: http://github.com/jbenet/multihash
435470
[promise]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise
471+
[UnixFS]: https://github.com/ipfs/specs/tree/master/unixfs

0 commit comments

Comments
 (0)