@@ -93,9 +93,9 @@ ipfs.files.createAddStream(function (err, stream) {
93
93
94
94
95
95
96
- #### ` cat `
96
+ #### ` cat `
97
97
98
- > Streams the file at the given IPFS multihash..
98
+ > Streams the file at the given IPFS multihash.
99
99
100
100
##### ` Go ` ** WIP**
101
101
@@ -116,3 +116,43 @@ ipfs.files.cat(multihash, function (err, file) {
116
116
})
117
117
```
118
118
119
+
120
+ #### ` get `
121
+ > Get [ UnixFS] [ ] files from IPFS.
122
+
123
+ ##### ` Go ` ** WIP**
124
+
125
+ ##### ` JavaScript ` - ipfs.files.get(hash, [ callback] )
126
+
127
+ Where ` hash ` is an IPFS multiaddress or multihash.
128
+
129
+ ` callback ` must follow ` function (err, stream) {} ` signature, where ` err ` is an
130
+ error if the operation was not successful. ` stream ` will be a Readable stream in
131
+ [ * object mode* ] ( https://nodejs.org/api/stream.html#stream_object_mode ) ,
132
+ outputting objects of the form
133
+
134
+ ``` js
135
+ {
136
+ path: ' /tmp/myfile.txt' ,
137
+ content: < Readable stream>
138
+ }
139
+ ```
140
+
141
+ Here, each ` path ` corresponds to the name of a file, and ` content ` is a regular
142
+ Readable stream with the raw contents of that file.
143
+
144
+ If no ` callback ` is passed, a promise is returned with the Readable stream.
145
+
146
+ Example:
147
+
148
+ ``` js
149
+ var multiaddr = ' /ipfs/QmQ2r6iMNpky5f1m4cnm3Yqw8VSvjuKpTcK1X7dBR1LkJF'
150
+ ipfs .files .get (multiaddr, function (err , stream ) {
151
+ stream .on (' data' , (file ) => {
152
+ // write the file's path and contents to standard out
153
+ console .log (file .path )
154
+ file .content .pipe (process .stdout )
155
+ })
156
+ })
157
+ ```
158
+
0 commit comments