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

Commit f87405c

Browse files
authored
Merge pull request #143 from ipfs/feat/support-path
feat: add support for paths on get and cat
2 parents 3d4a46c + 4cae543 commit f87405c

File tree

4 files changed

+244
-197
lines changed

4 files changed

+244
-197
lines changed

API/files/README.md

Lines changed: 20 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -111,19 +111,24 @@ A great source of [examples][] can be found in the tests for this API.
111111
112112
##### `Go` **WIP**
113113

114-
##### `JavaScript` - ipfs.files.cat(multihash, [callback])
114+
##### `JavaScript` - ipfs.files.cat(ipfsPath, [callback])
115115

116-
`multihash` is a [multihash][] which can be passed as
116+
ipfsPath can be of type:
117117

118-
- Buffer, the raw Buffer of the multihash
119-
- String, the base58 encoded version of the multihash
118+
- `multihash` is a [multihash][] which can be passed as
119+
- Buffer, the raw Buffer of the multihash
120+
- String, the base58 encoded version of the multihash
121+
- String, including the ipfs handler, a multihash and a path to traverse to, ie:
122+
- '/ipfs/QmXEmhrMpbVvTh61FNAxP9nU7ygVtyvZA8HZDUaqQCAb66'
123+
- '/ipfs/QmXEmhrMpbVvTh61FNAxP9nU7ygVtyvZA8HZDUaqQCAb66/a.txt'
124+
- 'QmXEmhrMpbVvTh61FNAxP9nU7ygVtyvZA8HZDUaqQCAb66/a.txt'
120125

121126
`callback` must follow `function (err, stream) {}` signature, where `err` is an error if the operation was not successful and `stream` is a readable stream of the file.
122127

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

125130
```JavaScript
126-
ipfs.files.cat(multihash, function (err, file) {
131+
ipfs.files.cat(ipfsPath, function (err, file) {
127132
// file will be a stream containing the data of the file requested
128133
})
129134
```
@@ -136,9 +141,17 @@ A great source of [examples][] can be found in the tests for this API.
136141
137142
##### `Go` **WIP**
138143

139-
##### `JavaScript` - ipfs.files.get(multihash, [callback])
144+
##### `JavaScript` - ipfs.files.get(ipfsPath, [callback])
140145

141-
Where `multihash` is an IPFS multihash or string multihash.
146+
ipfsPath can be of type:
147+
148+
- `multihash` is a [multihash][] which can be passed as
149+
- Buffer, the raw Buffer of the multihash
150+
- String, the base58 encoded version of the multihash
151+
- String, including the ipfs handler, a multihash and a path to traverse to, ie:
152+
- '/ipfs/QmXEmhrMpbVvTh61FNAxP9nU7ygVtyvZA8HZDUaqQCAb66'
153+
- '/ipfs/QmXEmhrMpbVvTh61FNAxP9nU7ygVtyvZA8HZDUaqQCAb66/a.txt'
154+
- 'QmXEmhrMpbVvTh61FNAxP9nU7ygVtyvZA8HZDUaqQCAb66/a.txt'
142155

143156
`callback` must follow `function (err, stream) {}` signature, where `err` is an
144157
error if the operation was not successful. `stream` will be a Readable stream in

package-lock.json

Lines changed: 1 addition & 42 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,4 +63,4 @@
6363
6464
"nginnever <[email protected]>"
6565
]
66-
}
66+
}

0 commit comments

Comments
 (0)