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

Commit

Permalink
doc: Documents the begin/end arguments to ipfs.files.cat and friends
Browse files Browse the repository at this point in the history
  • Loading branch information
achingbrain committed Mar 29, 2018
1 parent bad70ac commit 7fd182e
Showing 1 changed file with 18 additions and 6 deletions.
24 changes: 18 additions & 6 deletions SPEC/FILES.md
Original file line number Diff line number Diff line change
Expand Up @@ -161,9 +161,9 @@ pull(
##### `Go` **WIP**

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

ipfsPath can be of type:
`ipfsPath` can be of type:

- [`cid`][cid] of type:
- [Buffer][b], the raw Buffer of the cid
Expand All @@ -173,6 +173,10 @@ ipfsPath can be of type:
- '/ipfs/QmXEmhrMpbVvTh61FNAxP9nU7ygVtyvZA8HZDUaqQCAb66/a.txt'
- 'QmXEmhrMpbVvTh61FNAxP9nU7ygVtyvZA8HZDUaqQCAb66/a.txt'

`options` is an optional object that may contain the following keys:
- `offset` is an optional byte offset to start the stream at
- `count` is an optional number of bytes to read from the stream

`callback` must follow `function (err, file) {}` signature, where `err` is an error if the operation was not successful and `file` is a [Buffer][b]

If no `callback` is passed, a promise is returned.
Expand All @@ -197,9 +201,9 @@ A great source of [examples][] can be found in the tests for this API.
##### `Go` **WIP**

##### `JavaScript` - ipfs.files.catReadableStream(ipfsPath) -> [Readable Stream][rs]
##### `JavaScript` - ipfs.files.catReadableStream(ipfsPath, [options]) -> [Readable Stream][rs]

ipfsPath can be of type:
`ipfsPath` can be of type:

- [`cid`][cid] of type:
- [Buffer][b], the raw Buffer of the cid
Expand All @@ -209,6 +213,10 @@ ipfsPath can be of type:
- '/ipfs/QmXEmhrMpbVvTh61FNAxP9nU7ygVtyvZA8HZDUaqQCAb66/a.txt'
- 'QmXEmhrMpbVvTh61FNAxP9nU7ygVtyvZA8HZDUaqQCAb66/a.txt'

`options` is an optional object that may contain the following keys:
- `offset` is an optional byte offset to start the stream at
- `count` is an optional number of bytes to read from the stream

Returns a [Readable Stream][rs] with the contents of the file.


Expand All @@ -225,9 +233,9 @@ A great source of [examples][] can be found in the tests for this API.
##### `Go` **WIP**

##### `JavaScript` - ipfs.files.catPullStream(ipfsPath) -> [Pull Stream][rs]
##### `JavaScript` - ipfs.files.catPullStream(ipfsPath, [options]) -> [Pull Stream][rs]

ipfsPath can be of type:
`ipfsPath` can be of type:

- [`cid`][cid] of type:
- [Buffer][b], the raw Buffer of the cid
Expand All @@ -237,6 +245,10 @@ ipfsPath can be of type:
- '/ipfs/QmXEmhrMpbVvTh61FNAxP9nU7ygVtyvZA8HZDUaqQCAb66/a.txt'
- 'QmXEmhrMpbVvTh61FNAxP9nU7ygVtyvZA8HZDUaqQCAb66/a.txt'

`options` is an optional object that may contain the following keys:
- `offset` is an optional byte offset to start the stream at
- `count` is an optional number of bytes to read from the stream

Returns a [Pull Stream][ps] with the contents of the file.

```JavaScript
Expand Down

0 comments on commit 7fd182e

Please sign in to comment.