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

Commit 60819f9

Browse files
Prabhakar PoudelAlan Shaw
Prabhakar Poudel
authored and
Alan Shaw
committed
docs(add): include all available options for ipfs.add function (#482)
fix a couple of grammatical errors arrange function index in alphabetical order add more options to ipfs.add doc rename cid-version to cidVersion in the docs closes: #429 License: MIT Signed-off-by: Prabhakar-Poudel <yuvrajzohan@gmail.com>
1 parent 425cbbf commit 60819f9

File tree

1 file changed

+48
-40
lines changed

1 file changed

+48
-40
lines changed

SPEC/FILES.md

Lines changed: 48 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,23 @@
11
# Files API
22

3-
> The files API enables users to use the File System abstraction of IPFS. There are two Files API, one at the top level, the original `add`, `cat`, `get` and `ls`, and another behind the [`files`, also known as MFS](https://github.com/ipfs/specs/issues/98). [We are currently going through a revamping process of this APIs to make them more user friendly](https://github.com/ipfs/interface-ipfs-core/issues/284).
3+
> The files API enables users to use the File System abstraction of IPFS. There are two Files API, one at the top level, the original `add`, `cat`, `get` and `ls`, and another behind the [`files`, also known as MFS](https://github.com/ipfs/specs/issues/98). [We are currently going through a revamping process of these APIs to make them more user-friendly](https://github.com/ipfs/interface-ipfs-core/issues/284).
44
55
- The Regular (top level) API for add, cat, get and ls Files on IPFS
66
- [add](#add)
7-
- [addReadableStream](#addreadablestream)
8-
- [addPullStream](#addpullstream)
97
- [addFromFs](#addfromfs)
10-
- [addFromURL](#addfromurl)
118
- [addFromStream](#addfromstream)
9+
- [addFromURL](#addfromurl)
10+
- [addPullStream](#addpullstream)
11+
- [addReadableStream](#addreadablestream)
1212
- [cat](#cat)
13-
- [catReadableStream](#catreadablestream)
1413
- [catPullStream](#catpullstream)
14+
- [catReadableStream](#catreadablestream)
1515
- [get](#get)
16-
- [getReadableStream](#getreadablestream)
1716
- [getPullStream](#getpullstream)
17+
- [getReadableStream](#getreadablestream)
1818
- [ls](#ls)
19-
- [lsReadableStream](#lsreadablestream)
2019
- [lsPullStream](#lspullstream)
20+
- [lsReadableStream](#lsreadablestream)
2121
- The Files API, aka MFS (Mutable File System)
2222
- [files.cp](#filescp)
2323
- [files.flush](#filesflush)
@@ -56,19 +56,27 @@ If no `content` is passed, then the path is treated as an empty directory
5656

5757
`options` is an optional object argument that might include the following keys:
5858

59-
- cid-version (integer, default 0): the CID version to use when storing the data (storage keys are based on the CID, including it's version)
60-
- progress (function): a function that will be called with the byte length of chunks as a file is added to ipfs.
61-
- recursive (boolean): for when a Path is passed, this option can be enabled to add recursively all the files.
62-
- hashAlg || hash (string): multihash hashing algorithm to use. (default: `sha2-256`) [The list of all possible values]( https://github.com/multiformats/js-multihash/blob/master/src/constants.js#L5-L343)
63-
- wrapWithDirectory (boolean): adds a wrapping node around the content.
64-
- onlyHash (boolean): doesn't actually add the file to IPFS, but rather calculates its hash.
65-
- pin (boolean, default true): pin this object when adding.
66-
- raw-leaves (boolean, default false): if true, DAG leaves will contain raw file data and not be wrapped in a protobuf
67-
- chunker (string, default size-262144): chunking algorithm used to build ipfs DAGs. Available formats:
59+
- chunker (string, default `size-262144`): chunking algorithm used to build ipfs DAGs. Available formats:
6860
- size-{size}
6961
- rabin
7062
- rabin-{avg}
7163
- rabin-{min}-{avg}-{max}
64+
- cidVersion (integer, default 0): the CID version to use when storing the data (storage keys are based on the CID, including its version).
65+
- cidBase (string, default `base58btc`): Number base to display CIDs in. [The list of all possible values](https://github.com/multiformats/js-multibase/blob/master/src/constants.js).
66+
- enableShardingExperiment: allows to create directories with an unlimited number of entries currently size of unixfs directories is limited by the maximum block size. Note that this is an experimental feature.
67+
- hashAlg || hash (string, default `sha2-256`): multihash hashing algorithm to use. [The list of all possible values]( https://github.com/multiformats/js-multihash/blob/master/src/constants.js#L5-L343).
68+
- onlyHash (boolean, default false): doesn't actually add the file to IPFS, but rather calculates its hash.
69+
- pin (boolean, default true): pin this object when adding.
70+
- progress (function): a function that will be called with the byte length of chunks as a file is added to ipfs.
71+
- quiet (boolean, default false): writes a minimal output.
72+
- quieter (boolean, default false): writes only final hash.
73+
- rawLeaves (boolean, default false): if true, DAG leaves will contain raw file data and not be wrapped in a protobuf.
74+
- recursive (boolean, default false): for when a Path is passed, this option can be enabled to add recursively all the files.
75+
- shardSplitThreshold (integer, default 1000): specifies the maximum size of unsharded directory that can be generated.
76+
- silent (boolean, default false): writes no output.
77+
- trickle (boolean, default false): if true will use the trickle DAG format for DAG generation.
78+
[Trickle definition from go-ipfs documentation](https://godoc.org/github.com/ipsn/go-ipfs/gxlibs/github.com/ipfs/go-unixfs/importer/trickle).
79+
- wrapWithDirectory (boolean, default false): adds a wrapping node around the content.
7280

7381
`callback` must follow `function (err, res) {}` signature, where `err` is an error if the operation was not successful. `res` will be an array of:
7482

@@ -144,7 +152,7 @@ Returns a Readable Stream of class Duplex, where objects can be written of the f
144152

145153
`options` is an optional object argument that might include the following keys:
146154

147-
- cid-version (integer, default 0): the CID version to use when storing the data (storage keys are based on the CID, including it's version)
155+
- cidVersion (integer, default 0): the CID version to use when storing the data (storage keys are based on the CID, including its version)
148156
- progress (function): a function that will be called with the byte length of chunks as a file is added to ipfs.
149157
- hashAlg || hash (string): multihash hashing algorithm to use. (default: `sha2-256`) [The list of all possible values]( https://github.com/multiformats/js-multihash/blob/master/src/constants.js#L5-L343)
150158
- wrapWithDirectory (boolean): adds a wrapping node around the content
@@ -192,7 +200,7 @@ Returns a Pull Stream, where objects can be written of the forms
192200

193201
`options` is an optional object argument that might include the following keys:
194202

195-
- cid-version (integer, default 0): the CID version to use when storing the data (storage keys are based on the CID, including it's version)
203+
- cidVersion (integer, default 0): the CID version to use when storing the data (storage keys are based on the CID, including its version)
196204
- progress (function): a function that will be called with the byte length of chunks as a file is added to ipfs.
197205
- hashAlg || hash (string): multihash hashing algorithm to use. (default: `sha2-256`) [The list of all possible values]( https://github.com/multiformats/js-multihash/blob/master/src/constants.js#L5-L343)
198206
- wrapWithDirectory (boolean): adds a wrapping node around the content
@@ -225,7 +233,7 @@ pull(
225233
226234
##### `ipfs.addFromFs(path, [options], [callback])`
227235

228-
Reads a file or folder from `path` on the filesystem and adds it to IPFS.
236+
Reads a file or folder from `path` on the filesystem and adds it to IPFS.
229237

230238
Options:
231239
- **recursive**: If `path` is a directory, use option `{ recursive: true }` to add the directory and all its sub-directories.
@@ -529,7 +537,7 @@ A great source of [examples][] can be found in the tests for this API.
529537
530538
##### `ipfs.ls(ipfsPath, [callback])`
531539

532-
> **Note:** ipfs.files.ls is currently only for MFS directories. The goal is to converge both functionality.
540+
> **Note:** ipfs.files.ls is currently only for MFS directories. The goal is to converge both functionalities.
533541
534542
ipfsPath can be of type:
535543

@@ -576,7 +584,7 @@ A great source of [examples][] can be found in the tests for this API.
576584
577585
##### `ipfs.lsReadableStream(ipfsPath)` -> [Readable Stream][rs]
578586

579-
> **Note:** ipfs.files.ls is currently only for MFS directories. The goal is to converge both functionality.
587+
> **Note:** ipfs.files.ls is currently only for MFS directories. The goal is to converge both functionalities.
580588
581589
ipfsPath can be of type:
582590

@@ -622,7 +630,7 @@ A great source of [examples][] can be found in the tests for this API.
622630
623631
##### `ipfs.lsPullStream(ipfsPath)` -> [Pull Stream][ps]
624632

625-
> **Note:** ipfs.files.ls is currently only for MFS directories. The goal is to converge both functionality.
633+
> **Note:** ipfs.files.ls is currently only for MFS directories. The goal is to converge both functionalities.
626634
627635

628636
ipfsPath can be of type:
@@ -693,7 +701,7 @@ Where:
693701
- `format` is what type of nodes to write any newly created directories as (default: `dag-pb`)
694702
- `hashAlg` is which algorithm to use when creating CIDs for newly created directories. (default: `sha2-256`) [The list of all possible values]( https://github.com/multiformats/js-multihash/blob/master/src/constants.js#L5-L343)
695703
- `flush` is a Boolean value to decide whether or not to immediately flush MFS changes to disk (default: true)
696-
- `callback` is an optional function with the signature `function (error) {}`, where `error` may be an Error that occured if the operation was not successful
704+
- `callback` is an optional function with the signature `function (error) {}`, where `error` may be an Error that occurs if the operation is not successful
697705

698706
If `from` has multiple values then `to` must be a directory.
699707

@@ -744,7 +752,7 @@ Where:
744752
- `format` is what type of nodes to write any newly created directories as (default: `dag-pb`)
745753
- `hashAlg` is which algorithm to use when creating CIDs for newly created directories (default: `sha2-256`) [The list of all possible values]( https://github.com/multiformats/js-multihash/blob/master/src/constants.js#L5-L343)
746754
- `flush` is a Boolean value to decide whether or not to immediately flush MFS changes to disk (default: true)
747-
- `callback` is an optional function with the signature `function (error) {}`, where `error` may be an Error that occured if the operation was not successful
755+
- `callback` is an optional function with the signature `function (error) {}`, where `error` may be an Error that occurs if the operation is not successful
748756

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

@@ -772,14 +780,14 @@ Where:
772780
- `size` is a Boolean value to return only the size (default: false)
773781
- `withLocal` is a Boolean value to compute the amount of the dag that is local, and if possible the total size (default: false)
774782
- `cidBase` is which number base to use to format hashes - e.g. `base32`, `base64` etc (default: `base58btc`)
775-
- `callback` is an optional function with the signature `function (error, stats) {}`, where `error` may be an Error that occured if the operation was not successful and `stats` is an Object with the following keys:
783+
- `callback` is an optional function with the signature `function (error, stats) {}`, where `error` may be an Error that occurs if the operation is not successful and `stats` is an Object with the following keys:
776784

777785
- `hash` is a string with the hash
778786
- `size` is an integer with the file size in Bytes
779787
- `cumulativeSize` is an integer with the size of the DAGNodes making up the file in Bytes
780788
- `type` is a string that can be either `directory` or `file`
781789
- `blocks` if `type` is `directory`, this is the number of files in the directory. If it is `file` it is the number of blocks that make up the file
782-
- `withLocality` is a boolean to indicate if locality information are present
790+
- `withLocality` is a boolean to indicate if locality information is present
783791
- `local` is a boolean to indicate if the queried dag is fully present locally
784792
- `sizeLocal` is an integer indicating the cumulative size of the data present locally
785793

@@ -812,7 +820,7 @@ Where:
812820
- `paths` are one or more paths to remove
813821
- `options` is an optional Object that might contain the following keys:
814822
- `recursive` is a Boolean value to decide whether or not to remove directories recursively (default: false)
815-
- `callback` is an optional function with the signature `function (error) {}`, where `error` may be an Error that occured if the operation was not successful
823+
- `callback` is an optional function with the signature `function (error) {}`, where `error` may be an Error that occurs if the operation is not successful
816824

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

@@ -852,8 +860,8 @@ Where:
852860
- `path` is the path of the file to read and must point to a file (and not a directory)
853861
- `options` is an optional Object that might contain the following keys:
854862
- `offset` is an Integer with the byte offset to begin reading from (default: 0)
855-
- `length` is an Integer with the maximum number of bytes to read (default: Read to end of stream)
856-
- `callback` is an optional function with the signature `function (error, buffer) {}`, where `error` may be an Error that occured if the operation was not successful and `buffer` is a [`Buffer`][b] with the contents of `path`
863+
- `length` is an Integer with the maximum number of bytes to read (default: Read to the end of stream)
864+
- `callback` is an optional function with the signature `function (error, buffer) {}`, where `error` may be an Error that occurs if the operation is not successful and `buffer` is a [`Buffer`][b] with the contents of `path`
857865

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

@@ -880,7 +888,7 @@ Where:
880888
- `path` is the path of the file to read and must point to a file (and not a directory)
881889
- `options` is an optional Object that might contain the following keys:
882890
- `offset` is an Integer with the byte offset to begin reading from (default: 0)
883-
- `length` is an Integer with the maximum number of bytes to read (default: Read to end of stream)
891+
- `length` is an Integer with the maximum number of bytes to read (default: Read to the end of stream)
884892

885893
Returns a [`ReadableStream`][rs] with the contents of `path`.
886894

@@ -904,7 +912,7 @@ Where:
904912
- `path` is the path of the file to read and must point to a file (and not a directory)
905913
- `options` is an optional Object that might contain the following keys:
906914
- `offset` is an Integer with the byte offset to begin reading from (default: 0)
907-
- `length` is an Integer with the maximum number of bytes to read (default: Read to end of stream)
915+
- `length` is an Integer with the maximum number of bytes to read (default: Read to the end of stream)
908916

909917
Returns a [`PullStream`][ps] with the contents of `path`.
910918

@@ -941,9 +949,9 @@ Where:
941949
- `truncate` is a Boolean to indicate if the file should be truncated after writing all the bytes from `content` (default: false)
942950
- `parents` is a Boolean value to decide whether or not to make the parent directories if they don't exist (default: false)
943951
- `length` is an Integer with the maximum number of bytes to read (default: Read all bytes from `content`)
944-
- `raw-leaves`: if true, DAG leaves will contain raw file data and not be wrapped in a protobuf (boolean, default false)
945-
- `cid-version`: the CID version to use when storing the data (storage keys are based on the CID, including it's version) (integer, default 0)
946-
- `callback` is an optional function with the signature `function (error) {}`, where `error` may be an Error that occured if the operation was not successful
952+
- `rawLeaves`: if true, DAG leaves will contain raw file data and not be wrapped in a protobuf (boolean, default false)
953+
- `cidVersion`: the CID version to use when storing the data (storage keys are based on the CID, including its version) (integer, default 0)
954+
- `callback` is an optional function with the signature `function (error) {}`, where `error` may be an Error that occurs if the operation is not successful
947955

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

@@ -970,7 +978,7 @@ Where:
970978
- `format` is what type of nodes to write any newly created directories as (default: `dag-pb`)
971979
- `hashAlg` is which algorithm to use when creating CIDs for newly created directories (default: `sha2-256`) [The list of all possible values]( https://github.com/multiformats/js-multihash/blob/master/src/constants.js#L5-L343)
972980
- `flush` is a Boolean value to decide whether or not to immediately flush MFS changes to disk (default: true)
973-
- `callback` is an optional function with the signature `function (error) {}`, where `error` may be an Error that occured if the operation was not successful
981+
- `callback` is an optional function with the signature `function (error) {}`, where `error` may be an Error that occurs if the operation is not successful
974982

975983
If `from` has multiple values then `to` must be a directory.
976984

@@ -980,7 +988,7 @@ If `from` has a single value and `to` exists and is a file, `from` must be a fil
980988

981989
If `from` is an IPFS path, and an MFS path exists with the same name, the IPFS path will be chosen.
982990

983-
All values of `from` will be removed after the operation is complete, unless they are an IPFS path.
991+
All values of `from` will be removed after the operation is complete unless they are an IPFS path.
984992

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

@@ -1014,8 +1022,8 @@ ipfs.files.mv('/src-file1', '/src-file2', '/dst-dir', (err) => {
10141022

10151023
Where:
10161024

1017-
- `paths` are an optional string paths to flush (default: `/`)
1018-
- `callback` is an optional function with the signature `function (error) {}`, where `error` may be an Error that occured if the operation was not successful
1025+
- `paths` are optional string paths to flush (default: `/`)
1026+
- `callback` is an optional function with the signature `function (error) {}`, where `error` may be an Error that occurs if the operation is not successful
10191027

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

@@ -1041,8 +1049,8 @@ Where:
10411049
- `options` is an optional Object that might contain the following keys:
10421050
- `long` is a Boolean value to decide whether or not to populate `type`, `size` and `hash` (default: false)
10431051
- `cidBase` is which number base to use to format hashes - e.g. `base32`, `base64` etc (default: `base58btc`)
1044-
- `sort` is a Boolean value, if true entries will be sorted by filename (default: false)
1045-
- `callback` is an optional function with the signature `function (error, files) {}`, where `error` may be an Error that occured if the operation was not successful and `files` is an array containing Objects that contain the following keys:
1052+
- `sort` is a Boolean value. If true entries will be sorted by filename (default: false)
1053+
- `callback` is an optional function with the signature `function (error, files) {}`, where `error` may be an Error that occurs if the operation is not successful and `files` is an array containing Objects that contain the following keys:
10461054

10471055
- `name` which is the file's name
10481056
- `type` which is the object's type (`directory` or `file`)

0 commit comments

Comments
 (0)