You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Mar 10, 2020. It is now read-only.
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>
Copy file name to clipboardExpand all lines: SPEC/FILES.md
+48-40Lines changed: 48 additions & 40 deletions
Original file line number
Diff line number
Diff line change
@@ -1,23 +1,23 @@
1
1
# Files API
2
2
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 userfriendly](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).
4
4
5
5
- The Regular (top level) API for add, cat, get and ls Files on IPFS
6
6
-[add](#add)
7
-
-[addReadableStream](#addreadablestream)
8
-
-[addPullStream](#addpullstream)
9
7
-[addFromFs](#addfromfs)
10
-
-[addFromURL](#addfromurl)
11
8
-[addFromStream](#addfromstream)
9
+
-[addFromURL](#addfromurl)
10
+
-[addPullStream](#addpullstream)
11
+
-[addReadableStream](#addreadablestream)
12
12
-[cat](#cat)
13
-
-[catReadableStream](#catreadablestream)
14
13
-[catPullStream](#catpullstream)
14
+
-[catReadableStream](#catreadablestream)
15
15
-[get](#get)
16
-
-[getReadableStream](#getreadablestream)
17
16
-[getPullStream](#getpullstream)
17
+
-[getReadableStream](#getreadablestream)
18
18
-[ls](#ls)
19
-
-[lsReadableStream](#lsreadablestream)
20
19
-[lsPullStream](#lspullstream)
20
+
-[lsReadableStream](#lsreadablestream)
21
21
- The Files API, aka MFS (Mutable File System)
22
22
-[files.cp](#filescp)
23
23
-[files.flush](#filesflush)
@@ -56,19 +56,27 @@ If no `content` is passed, then the path is treated as an empty directory
56
56
57
57
`options` is an optional object argument that might include the following keys:
58
58
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:
68
60
- size-{size}
69
61
- rabin
70
62
- rabin-{avg}
71
63
- 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.
72
80
73
81
`callback` must follow `function (err, res) {}` signature, where `err` is an error if the operation was not successful. `res` will be an array of:
74
82
@@ -144,7 +152,7 @@ Returns a Readable Stream of class Duplex, where objects can be written of the f
144
152
145
153
`options` is an optional object argument that might include the following keys:
146
154
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)
148
156
- progress (function): a function that will be called with the byte length of chunks as a file is added to ipfs.
149
157
- 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)
150
158
- 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
192
200
193
201
`options` is an optional object argument that might include the following keys:
194
202
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)
196
204
- progress (function): a function that will be called with the byte length of chunks as a file is added to ipfs.
197
205
- 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)
198
206
- wrapWithDirectory (boolean): adds a wrapping node around the content
> **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.
626
634
627
635
628
636
ipfsPath can be of type:
@@ -693,7 +701,7 @@ Where:
693
701
-`format` is what type of nodes to write any newly created directories as (default: `dag-pb`)
694
702
-`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)
695
703
-`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
697
705
698
706
If `from` has multiple values then `to` must be a directory.
699
707
@@ -744,7 +752,7 @@ Where:
744
752
-`format` is what type of nodes to write any newly created directories as (default: `dag-pb`)
745
753
-`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)
746
754
-`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
748
756
749
757
If no `callback` is passed, a promise is returned.
750
758
@@ -772,14 +780,14 @@ Where:
772
780
-`size` is a Boolean value to return only the size (default: false)
773
781
-`withLocal` is a Boolean value to compute the amount of the dag that is local, and if possible the total size (default: false)
774
782
-`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:
776
784
777
785
-`hash` is a string with the hash
778
786
-`size` is an integer with the file size in Bytes
779
787
-`cumulativeSize` is an integer with the size of the DAGNodes making up the file in Bytes
780
788
-`type` is a string that can be either `directory` or `file`
781
789
-`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
783
791
-`local` is a boolean to indicate if the queried dag is fully present locally
784
792
-`sizeLocal` is an integer indicating the cumulative size of the data present locally
785
793
@@ -812,7 +820,7 @@ Where:
812
820
-`paths` are one or more paths to remove
813
821
-`options` is an optional Object that might contain the following keys:
814
822
-`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
816
824
817
825
If no `callback` is passed, a promise is returned.
818
826
@@ -852,8 +860,8 @@ Where:
852
860
-`path` is the path of the file to read and must point to a file (and not a directory)
853
861
-`options` is an optional Object that might contain the following keys:
854
862
-`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`
857
865
858
866
If no `callback` is passed, a promise is returned.
859
867
@@ -880,7 +888,7 @@ Where:
880
888
-`path` is the path of the file to read and must point to a file (and not a directory)
881
889
-`options` is an optional Object that might contain the following keys:
882
890
-`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)
884
892
885
893
Returns a [`ReadableStream`][rs] with the contents of `path`.
886
894
@@ -904,7 +912,7 @@ Where:
904
912
-`path` is the path of the file to read and must point to a file (and not a directory)
905
913
-`options` is an optional Object that might contain the following keys:
906
914
-`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)
908
916
909
917
Returns a [`PullStream`][ps] with the contents of `path`.
910
918
@@ -941,9 +949,9 @@ Where:
941
949
-`truncate` is a Boolean to indicate if the file should be truncated after writing all the bytes from `content` (default: false)
942
950
-`parents` is a Boolean value to decide whether or not to make the parent directories if they don't exist (default: false)
943
951
-`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
947
955
948
956
If no `callback` is passed, a promise is returned.
949
957
@@ -970,7 +978,7 @@ Where:
970
978
-`format` is what type of nodes to write any newly created directories as (default: `dag-pb`)
971
979
-`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)
972
980
-`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
974
982
975
983
If `from` has multiple values then `to` must be a directory.
976
984
@@ -980,7 +988,7 @@ If `from` has a single value and `to` exists and is a file, `from` must be a fil
980
988
981
989
If `from` is an IPFS path, and an MFS path exists with the same name, the IPFS path will be chosen.
982
990
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.
984
992
985
993
If no `callback` is passed, a promise is returned.
-`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
1019
1027
1020
1028
If no `callback` is passed, a promise is returned.
1021
1029
@@ -1041,8 +1049,8 @@ Where:
1041
1049
-`options` is an optional Object that might contain the following keys:
1042
1050
-`long` is a Boolean value to decide whether or not to populate `type`, `size` and `hash` (default: false)
1043
1051
-`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:
1046
1054
1047
1055
-`name` which is the file's name
1048
1056
-`type` which is the object's type (`directory` or `file`)
0 commit comments