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

feat: add support for paths on get and cat #143

Merged
merged 1 commit into from
May 29, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 20 additions & 7 deletions API/files/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -111,19 +111,24 @@ A great source of [examples][] can be found in the tests for this API.

##### `Go` **WIP**

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

`multihash` is a [multihash][] which can be passed as
ipfsPath can be of type:

- Buffer, the raw Buffer of the multihash
- String, the base58 encoded version of the multihash
- `multihash` is a [multihash][] which can be passed as
- Buffer, the raw Buffer of the multihash
- String, the base58 encoded version of the multihash
- String, including the ipfs handler, a multihash and a path to traverse to, ie:
- '/ipfs/QmXEmhrMpbVvTh61FNAxP9nU7ygVtyvZA8HZDUaqQCAb66'
- '/ipfs/QmXEmhrMpbVvTh61FNAxP9nU7ygVtyvZA8HZDUaqQCAb66/a.txt'
- 'QmXEmhrMpbVvTh61FNAxP9nU7ygVtyvZA8HZDUaqQCAb66/a.txt'

`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.

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

```JavaScript
ipfs.files.cat(multihash, function (err, file) {
ipfs.files.cat(ipfsPath, function (err, file) {
// file will be a stream containing the data of the file requested
})
```
Expand All @@ -136,9 +141,17 @@ A great source of [examples][] can be found in the tests for this API.

##### `Go` **WIP**

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

Where `multihash` is an IPFS multihash or string multihash.
ipfsPath can be of type:

- `multihash` is a [multihash][] which can be passed as
- Buffer, the raw Buffer of the multihash
- String, the base58 encoded version of the multihash
- String, including the ipfs handler, a multihash and a path to traverse to, ie:
- '/ipfs/QmXEmhrMpbVvTh61FNAxP9nU7ygVtyvZA8HZDUaqQCAb66'
- '/ipfs/QmXEmhrMpbVvTh61FNAxP9nU7ygVtyvZA8HZDUaqQCAb66/a.txt'
- 'QmXEmhrMpbVvTh61FNAxP9nU7ygVtyvZA8HZDUaqQCAb66/a.txt'

`callback` must follow `function (err, stream) {}` signature, where `err` is an
error if the operation was not successful. `stream` will be a Readable stream in
Expand Down
43 changes: 1 addition & 42 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -63,4 +63,4 @@
"haad <haad@headbanggames.com>",
"nginnever <ginneversource@gmail.com>"
]
}
}
Loading