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 Apr 29, 2020. It is now read-only.
The `import` object is a duplex pull stream that takes objects of the form:
117
-
118
-
```js
119
-
{
120
-
path:'a name',
121
-
content: (Buffer or Readable stream)
122
-
}
123
-
```
124
-
125
-
`import` will output file info objects as files get stored in IPFS. When stats on a node are emitted they are guaranteed to have been written.
126
-
127
-
`dag` is an instance of the [`IPLD Resolver`](https://github.com/ipld/js-ipld-resolver) or the [`js-ipfs``dag api`](https://github.com/ipfs/interface-ipfs-core/blob/master/SPEC/DAG.md)
128
-
129
-
The input's file paths and directory structure will be preserved in the [`dag-pb`](https://github.com/ipld/js-ipld-dag-pb) created nodes.
130
-
131
-
`options` is an JavaScript option that might include the following keys:
132
-
133
-
-`wrap` (boolean, defaults to false): if true, a wrapping node will be created
134
-
-`shardSplitThreshold` (positive integer, defaults to 1000): the number of directory entries above which we decide to use a sharding directory builder (instead of the default flat one)
135
-
-`chunker` (string, defaults to `"fixed"`): the chunking strategy. Now only supports `"fixed"`
136
-
-`chunkerOptions` (object, optional): the options for the chunker. Defaults to an object with the following properties:
137
-
-`maxChunkSize` (positive integer, defaults to `262144`): the maximum chunk size for the `fixed` chunker.
138
-
-`strategy` (string, defaults to `"balanced"`): the DAG builder strategy name. Supports:
-`maxChildrenPerNode` (positive integer, defaults to `174`): the maximum children per node for the `balanced` and `trickle` DAG builder strategies
143
-
-`layerRepeat` (positive integer, defaults to 4): (only applicable to the `trickle` DAG builder strategy). The maximum repetition of parent nodes for each layer of the tree.
144
-
-`reduceSingleLeafToSelf` (boolean, defaults to `true`): optimization for, when reducing a set of nodes with one node, reduce it to that node.
145
-
-`dirBuilder` (object): the options for the directory builder
146
-
-`hamt` (object): the options for the HAMT sharded directory builder
147
-
- bits (positive integer, defaults to `8`): the number of bits at each bucket of the HAMT
148
-
-`progress` (function): a function that will be called with the byte length of chunks as a file is added to ipfs.
149
-
-`onlyHash` (boolean, defaults to false): Only chunk and hash - do not write to disk
150
-
-`hashAlg` (string): multihash hashing algorithm to use
151
-
-`cidVersion` (integer, default 0): the CID version to use when storing the data (storage keys are based on the CID, _including_ it's version)
152
-
-`rawLeaves` (boolean, defaults to false): When a file would span multiple DAGNodes, if this is true the leaf nodes will not be wrapped in `UnixFS` protobufs and will instead contain the raw file bytes
153
-
-`leafType` (string, defaults to `'file'`) what type of UnixFS node leaves should be - can be `'file'` or `'raw'` (ignored when `rawLeaves` is `true`)
154
-
155
-
### Exporter
156
-
157
-
#### Exporter example
38
+
### Example
158
39
159
40
```js
160
41
// Create an export source pull-stream cid or ipfs path you want to export and a
161
42
// <dag or ipld-resolver instance> to fetch the file from
162
-
constfilesStream=Exporter(<cid or ipfsPath>, <dag or ipld-resolver instance>)
### new Exporter(<cidoripfsPath>, <dagoripld-resolver>, <options>)
72
+
### exporter(cid, ipld, options)
175
73
176
-
Uses the given [dag API][] or an [ipld-resolver instance][] to fetch an IPFS [UnixFS][] object(s) by their multiaddress.
74
+
Uses the given [dag API][] or an [ipld-resolver instance][] to fetch an IPFS [UnixFS][] object(s) by their CID.
177
75
178
-
Creates a new readable stream in object mode that outputs objects of the form
76
+
Creates a new pull stream that outputs objects of the form
179
77
180
78
```js
181
79
{
182
80
path:'a name',
183
-
content:(Buffer or Readable stream)
81
+
content:<pull stream>
184
82
}
185
83
```
186
84
187
85
#### `offset` and `length`
188
86
189
-
`offset` and `length` arguments can optionally be passed to the reader function. These will cause the returned stream to only emit bytes starting at `offset` and with length of `length`.
87
+
`offset` and `length` arguments can optionally be passed to the exporter function. These will cause the returned stream to only emit bytes starting at `offset` and with length of `length`.
190
88
191
-
See [the tests](test/reader.js) for examples of using these arguments.
89
+
See [the tests](test/exporter.js) for examples of using these arguments.
0 commit comments