Private
Optional
_modePrivate
_originalOptional
dataOptional
fanoutOptional
hashOptional
mtimeencode to protobuf Uint8Array
-Static
unmarshalDecode from protobuf https://github.com/ipfs/specs/blob/master/UNIXFS.md
-Generated using TypeDoc
Private
Optional
_modePrivate
_originalOptional
dataOptional
fanoutOptional
hashOptional
mtimeencode to protobuf Uint8Array
+Static
unmarshalDecode from protobuf https://github.com/ipfs/specs/blob/master/UNIXFS.md
+Generated using TypeDoc
Uses the given blockstore instance to fetch an IPFS node by a CID or path.
+Uses the given blockstore instance to fetch an IPFS node by a CID or path.
Returns a Promise which resolves to a UnixFSEntry.
-import { exporter } from 'ipfs-unixfs-exporter'
import { CID } from 'multiformats/cid'
const cid = CID.parse('QmFoo')
const entry = await exporter(cid, blockstore, {
signal: AbortSignal.timeout(50000)
})
if (entry.type === 'file') {
for await (const chunk of entry.content()) {
// chunk is a Uint8Array
}
}
+
import { exporter } from 'ipfs-unixfs-exporter'
import { CID } from 'multiformats/cid'
const cid = CID.parse('QmFoo')
const entry = await exporter(cid, blockstore, {
signal: AbortSignal.timeout(50000)
})
if (entry.type === 'file') {
for await (const chunk of entry.content()) {
// chunk is a Uint8Array
}
}
-Generated using TypeDoc
Generated using TypeDoc
Returns an async iterator that yields all entries beneath a given CID or IPFS +
Returns an async iterator that yields all entries beneath a given CID or IPFS path, as well as the containing directory.
-import { recursive } from 'ipfs-unixfs-exporter'
const entries = []
for await (const child of recursive('Qmfoo/foo/bar', blockstore)) {
entries.push(entry)
}
// entries contains all children of the `Qmfoo/foo/bar` directory and it's children
+
import { recursive } from 'ipfs-unixfs-exporter'
const entries = []
for await (const child of recursive('Qmfoo/foo/bar', blockstore)) {
entries.push(entry)
}
// entries contains all children of the `Qmfoo/foo/bar` directory and it's children
-Generated using TypeDoc
Generated using TypeDoc
Returns an async iterator that yields entries for all segments in a path
-import { walkPath } from 'ipfs-unixfs-exporter'
const entries = []
for await (const entry of walkPath('Qmfoo/foo/bar/baz.txt', blockstore)) {
entries.push(entry)
}
// entries contains 4x `entry` objects
+walkPath | UnixFS Function walkPath
- walk
Path(path, blockstore, options?): AsyncGenerator<UnixFSEntry, void, any> Returns an async iterator that yields entries for all segments in a path
+Parameters
- path: string | CID<unknown, number, number, Version>
- blockstore: ReadableStorage
- options: ExporterOptions = {}
Returns AsyncGenerator<UnixFSEntry, void, any>
Example
import { walkPath } from 'ipfs-unixfs-exporter'
const entries = []
for await (const entry of walkPath('Qmfoo/foo/bar/baz.txt', blockstore)) {
entries.push(entry)
}
// entries contains 4x `entry` objects
-
Generated using TypeDoc
\ No newline at end of file
+
Generated using TypeDoc
Generated using TypeDoc
Generated using TypeDoc
Generated using TypeDoc
Generated using TypeDoc
importByteStream
accepts a single stream of Uint8Arrays and
+
importByteStream
accepts a single stream of Uint8Arrays and
returns a promise of a single ImportResult
.
import { importByteStream } from 'ipfs-unixfs-importer'
import { MemoryBlockstore } from 'blockstore-core'
// store blocks in memory, other blockstores are available
const blockstore = new MemoryBlockstore()
const input = [
Uint8Array.from([0, 1, 2, 3, 4]),
Uint8Array.from([5, 6, 7, 8, 9])
]
const entry = await importByteStream(input, blockstore)
+
import { importByteStream } from 'ipfs-unixfs-importer'
import { MemoryBlockstore } from 'blockstore-core'
// store blocks in memory, other blockstores are available
const blockstore = new MemoryBlockstore()
const input = [
Uint8Array.from([0, 1, 2, 3, 4]),
Uint8Array.from([5, 6, 7, 8, 9])
]
const entry = await importByteStream(input, blockstore)
-Generated using TypeDoc
Generated using TypeDoc
importBytes
accepts a single Uint8Array and returns a promise
+
importBytes
accepts a single Uint8Array and returns a promise
of a single ImportResult
.
import { importBytes } from 'ipfs-unixfs-importer'
import { MemoryBlockstore } from 'blockstore-core'
// store blocks in memory, other blockstores are available
const blockstore = new MemoryBlockstore()
const input = Uint8Array.from([0, 1, 2, 3, 4])
const entry = await importBytes(input, blockstore)
+
import { importBytes } from 'ipfs-unixfs-importer'
import { MemoryBlockstore } from 'blockstore-core'
// store blocks in memory, other blockstores are available
const blockstore = new MemoryBlockstore()
const input = Uint8Array.from([0, 1, 2, 3, 4])
const entry = await importBytes(input, blockstore)
-Generated using TypeDoc
Generated using TypeDoc
importDir
is similar to importer
except it accepts a single
+
importDir
is similar to importer
except it accepts a single
DirectoryCandidate
and returns a promise of a single ImportResult
instead of a stream of results.
import { importDirectory } from 'ipfs-unixfs-importer'
import { MemoryBlockstore } from 'blockstore-core'
// store blocks in memory, other blockstores are available
const blockstore = new MemoryBlockstore()
const input: DirectoryCandidate = {
path: './foo.txt'
}
const entry = await importDirectory(input, blockstore)
+
import { importDirectory } from 'ipfs-unixfs-importer'
import { MemoryBlockstore } from 'blockstore-core'
// store blocks in memory, other blockstores are available
const blockstore = new MemoryBlockstore()
const input: DirectoryCandidate = {
path: './foo.txt'
}
const entry = await importDirectory(input, blockstore)
-Generated using TypeDoc
Generated using TypeDoc
importFile
is similar to importer
except it accepts a single
+
importFile
is similar to importer
except it accepts a single
FileCandidate
and returns a promise of a single ImportResult
instead of a stream of results.
import { importFile } from 'ipfs-unixfs-importer'
import { MemoryBlockstore } from 'blockstore-core'
// store blocks in memory, other blockstores are available
const blockstore = new MemoryBlockstore()
const input: FileCandidate = {
path: './foo.txt',
content: Uint8Array.from([0, 1, 2, 3, 4])
}
const entry = await importFile(input, blockstore)
+
import { importFile } from 'ipfs-unixfs-importer'
import { MemoryBlockstore } from 'blockstore-core'
// store blocks in memory, other blockstores are available
const blockstore = new MemoryBlockstore()
const input: FileCandidate = {
path: './foo.txt',
content: Uint8Array.from([0, 1, 2, 3, 4])
}
const entry = await importFile(input, blockstore)
-Generated using TypeDoc
Generated using TypeDoc
The importer creates UnixFS DAGs and stores the blocks that make +
The importer creates UnixFS DAGs and stores the blocks that make them up in the passed blockstore.
-import { importer } from 'ipfs-unixfs-importer'
import { MemoryBlockstore } from 'blockstore-core'
// store blocks in memory, other blockstores are available
const blockstore = new MemoryBlockstore()
const input = [{
path: './foo.txt',
content: Uint8Array.from([0, 1, 2, 3, 4])
}, {
path: './bar.txt',
content: Uint8Array.from([0, 1, 2, 3, 4])
}]
for await (const entry of importer(input, blockstore)) {
console.info(entry)
// { cid: CID(), ... }
}
+
import { importer } from 'ipfs-unixfs-importer'
import { MemoryBlockstore } from 'blockstore-core'
// store blocks in memory, other blockstores are available
const blockstore = new MemoryBlockstore()
const input = [{
path: './foo.txt',
content: Uint8Array.from([0, 1, 2, 3, 4])
}, {
path: './bar.txt',
content: Uint8Array.from([0, 1, 2, 3, 4])
}]
for await (const entry of importer(input, blockstore)) {
console.info(entry)
// { cid: CID(), ... }
}
-Generated using TypeDoc
Generated using TypeDoc
Optional
options: BalancedOptionsGenerated using TypeDoc
Optional
options: BalancedOptionsGenerated using TypeDoc
Generated using TypeDoc
Generated using TypeDoc
Optional
options: TrickleOptionsGenerated using TypeDoc
Optional
options: TrickleOptionsGenerated using TypeDoc
Generated using TypeDoc
Generated using TypeDoc
Please be aware that all interactions related to this repo are subject to the IPFS Code of Conduct.
Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.
-Generated using TypeDoc
Generated using TypeDoc
Generated using TypeDoc
Generated using TypeDoc
Optional
blockOptional
dataOptional
fanoutOptional
hashOptional
modeOptional
mtimeOptional
typeGenerated using TypeDoc
Optional
blockOptional
dataOptional
fanoutOptional
hashOptional
modeOptional
mtimeOptional
typeGenerated using TypeDoc
How many bytes of the file have been read
-The size of the file being read - n.b. this may be +
How many bytes of the file have been read
+The size of the file being read - n.b. this may be
larger than total
if offset
/length
has been
specified
How many bytes of the file will be read - n.b. this may be +
How many bytes of the file will be read - n.b. this may be
smaller than fileSize
if offset
/length
have been
specified
Generated using TypeDoc
Generated using TypeDoc
Generated using TypeDoc
Generated using TypeDoc
The CID of the entry
-How far down the DAG the entry is
-The name of the entry
-The path of the entry within the DAG in which it was encountered
-The size of the entry
-A disambiguator to allow TypeScript to work out the type of the entry.
+The CID of the entry
+How far down the DAG the entry is
+The name of the entry
+The path of the entry within the DAG in which it was encountered
+The size of the entry
+A disambiguator to allow TypeScript to work out the type of the entry.
if (entry.type === 'file') {
// access UnixFSFile properties safely
}
if (entry.type === 'directory') {
// access UnixFSDirectory properties safely
}
-Optional
options: ExporterOptionsWhen entry
is a file or a raw
node, offset
and/or length
arguments can be passed to entry.content()
to return slices of data:
Optional
options: ExporterOptionsWhen entry
is a file or a raw
node, offset
and/or length
arguments can be passed to entry.content()
to return slices of data:
const length = 5
const data = new Uint8Array(length)
let offset = 0
for await (const chunk of entry.content({
offset: 0,
length
})) {
data.set(chunk, offset)
offset += chunk.length
}
// `data` contains the first 5 bytes of the file
return data
If entry
is a directory, passing offset
and/or length
to entry.content()
will limit the number of files returned from the directory.
const entries = []
for await (const entry of dir.content({
offset: 0,
length: 5
})) {
entries.push(entry)
}
// `entries` contains the first 5 files/directories in the directory
-Generated using TypeDoc
Generated using TypeDoc
Optional
blockWhen a DAG layer is encountered, all child nodes are loaded in parallel but +
Optional
blockWhen a DAG layer is encountered, all child nodes are loaded in parallel but
processed as they arrive. This allows us to load sibling nodes in advance
of yielding their bytes. Pass a value here to control the number of blocks
loaded in parallel. If a strict depth-first traversal is required, this
value should be set to 1
, otherwise the traversal order will tend to
resemble a breadth-first fan-out and yield a have stable ordering.
(default: undefined)
Optional
lengthAn optional length to read.
+Optional
lengthAn optional length to read.
If the CID resolves to a file this will be the number of bytes read from the file, otherwise if it's a directory it will be the number of directory entries read from the directory listing. (default: undefined)
-Optional
offsetAn optional offset to start reading at.
+Optional
offsetAn optional offset to start reading at.
If the CID resolves to a file this will be a byte offset within that file, otherwise if it's a directory it will be a directory entry offset within the directory listing. (default: undefined)
-Optional
onOptional
signalThis signal can be used to abort any long-lived operations such as fetching +
Optional
onOptional
signalThis signal can be used to abort any long-lived operations such as fetching blocks from the network. (default: undefined)
-Generated using TypeDoc
Generated using TypeDoc
Entries with a identity
codec CID return identity entries.
Entries with a identity
codec CID return identity entries.
These are entries where the data payload is stored in the CID itself, otherwise they are identical to RawNodes.
-The CID of the entry
-How far down the DAG the entry is
-The name of the entry
-The path of the entry within the DAG in which it was encountered
-The size of the entry
-A disambiguator to allow TypeScript to work out the type of the entry.
+The CID of the entry
+How far down the DAG the entry is
+The name of the entry
+The path of the entry within the DAG in which it was encountered
+The size of the entry
+A disambiguator to allow TypeScript to work out the type of the entry.
if (entry.type === 'file') {
// access UnixFSFile properties safely
}
if (entry.type === 'directory') {
// access UnixFSDirectory properties safely
}
-Optional
options: ExporterOptionsWhen entry
is a file or a raw
node, offset
and/or length
arguments can be passed to entry.content()
to return slices of data:
Optional
options: ExporterOptionsWhen entry
is a file or a raw
node, offset
and/or length
arguments can be passed to entry.content()
to return slices of data:
const length = 5
const data = new Uint8Array(length)
let offset = 0
for await (const chunk of entry.content({
offset: 0,
length
})) {
data.set(chunk, offset)
offset += chunk.length
}
// `data` contains the first 5 bytes of the file
return data
If entry
is a directory, passing offset
and/or length
to entry.content()
will limit the number of files returned from the directory.
const entries = []
for await (const entry of dir.content({
offset: 0,
length: 5
})) {
entries.push(entry)
}
// `entries` contains the first 5 files/directories in the directory
-Generated using TypeDoc
Generated using TypeDoc
Generated using TypeDoc
Generated using TypeDoc
Entries with a dag-cbor
or dag-json
codec CID return JavaScript object entries
The CID of the entry
-How far down the DAG the entry is
-The name of the entry
-The path of the entry within the DAG in which it was encountered
-The size of the entry
-A disambiguator to allow TypeScript to work out the type of the entry.
+Entries with a dag-cbor
or dag-json
codec CID return JavaScript object entries
The CID of the entry
+How far down the DAG the entry is
+The name of the entry
+The path of the entry within the DAG in which it was encountered
+The size of the entry
+A disambiguator to allow TypeScript to work out the type of the entry.
if (entry.type === 'file') {
// access UnixFSFile properties safely
}
if (entry.type === 'directory') {
// access UnixFSDirectory properties safely
}
-Optional
options: ExporterOptionsWhen entry
is a file or a raw
node, offset
and/or length
arguments can be passed to entry.content()
to return slices of data:
Optional
options: ExporterOptionsWhen entry
is a file or a raw
node, offset
and/or length
arguments can be passed to entry.content()
to return slices of data:
const length = 5
const data = new Uint8Array(length)
let offset = 0
for await (const chunk of entry.content({
offset: 0,
length
})) {
data.set(chunk, offset)
offset += chunk.length
}
// `data` contains the first 5 bytes of the file
return data
If entry
is a directory, passing offset
and/or length
to entry.content()
will limit the number of files returned from the directory.
const entries = []
for await (const entry of dir.content({
offset: 0,
length: 5
})) {
entries.push(entry)
}
// `entries` contains the first 5 files/directories in the directory
-Generated using TypeDoc
Generated using TypeDoc
Entries with a raw
codec CID return raw entries.
Entries with a raw
codec CID return raw entries.
entry.content()
returns an async iterator that yields a buffer containing the node content:
for await (const chunk of entry.content()) {
// chunk is a Buffer
}
Unless you an options object containing offset
and length
keys as an argument to entry.content()
, chunk
will be equal to entry.node
.
The CID of the entry
-How far down the DAG the entry is
-The name of the entry
-The path of the entry within the DAG in which it was encountered
-The size of the entry
-A disambiguator to allow TypeScript to work out the type of the entry.
+The CID of the entry
+How far down the DAG the entry is
+The name of the entry
+The path of the entry within the DAG in which it was encountered
+The size of the entry
+A disambiguator to allow TypeScript to work out the type of the entry.
if (entry.type === 'file') {
// access UnixFSFile properties safely
}
if (entry.type === 'directory') {
// access UnixFSDirectory properties safely
}
-Optional
options: ExporterOptionsWhen entry
is a file or a raw
node, offset
and/or length
arguments can be passed to entry.content()
to return slices of data:
Optional
options: ExporterOptionsWhen entry
is a file or a raw
node, offset
and/or length
arguments can be passed to entry.content()
to return slices of data:
const length = 5
const data = new Uint8Array(length)
let offset = 0
for await (const chunk of entry.content({
offset: 0,
length
})) {
data.set(chunk, offset)
offset += chunk.length
}
// `data` contains the first 5 bytes of the file
return data
If entry
is a directory, passing offset
and/or length
to entry.content()
will limit the number of files returned from the directory.
const entries = []
for await (const entry of dir.content({
offset: 0,
length: 5
})) {
entries.push(entry)
}
// `entries` contains the first 5 files/directories in the directory
-Generated using TypeDoc
Generated using TypeDoc
Generated using TypeDoc
Generated using TypeDoc
Generated using TypeDoc
Generated using TypeDoc
Generated using TypeDoc
Generated using TypeDoc
Generated using TypeDoc
Generated using TypeDoc
If the entry is a directory, entry.content()
returns further entry
objects:
If the entry is a directory, entry.content()
returns further entry
objects:
if (entry.type === 'directory') {
for await (const entry of dir.content()) {
console.info(entry.name)
}
}
-The CID of the entry
-How far down the DAG the entry is
-The name of the entry
-The path of the entry within the DAG in which it was encountered
-The size of the entry
-A disambiguator to allow TypeScript to work out the type of the entry.
+The CID of the entry
+How far down the DAG the entry is
+The name of the entry
+The path of the entry within the DAG in which it was encountered
+The size of the entry
+A disambiguator to allow TypeScript to work out the type of the entry.
if (entry.type === 'file') {
// access UnixFSFile properties safely
}
if (entry.type === 'directory') {
// access UnixFSDirectory properties safely
}
-Optional
options: ExporterOptionsWhen entry
is a file or a raw
node, offset
and/or length
arguments can be passed to entry.content()
to return slices of data:
Optional
options: ExporterOptionsWhen entry
is a file or a raw
node, offset
and/or length
arguments can be passed to entry.content()
to return slices of data:
const length = 5
const data = new Uint8Array(length)
let offset = 0
for await (const chunk of entry.content({
offset: 0,
length
})) {
data.set(chunk, offset)
offset += chunk.length
}
// `data` contains the first 5 bytes of the file
return data
If entry
is a directory, passing offset
and/or length
to entry.content()
will limit the number of files returned from the directory.
const entries = []
for await (const entry of dir.content({
offset: 0,
length: 5
})) {
entries.push(entry)
}
// `entries` contains the first 5 files/directories in the directory
-Generated using TypeDoc
Generated using TypeDoc
If the entry is a file, entry.content()
returns an async iterator that yields one or more Uint8Arrays containing the file content:
If the entry is a file, entry.content()
returns an async iterator that yields one or more Uint8Arrays containing the file content:
if (entry.type === 'file') {
for await (const chunk of entry.content()) {
// chunk is a Buffer
}
}
-The CID of the entry
-How far down the DAG the entry is
-The name of the entry
-The path of the entry within the DAG in which it was encountered
-The size of the entry
-A disambiguator to allow TypeScript to work out the type of the entry.
+The CID of the entry
+How far down the DAG the entry is
+The name of the entry
+The path of the entry within the DAG in which it was encountered
+The size of the entry
+A disambiguator to allow TypeScript to work out the type of the entry.
if (entry.type === 'file') {
// access UnixFSFile properties safely
}
if (entry.type === 'directory') {
// access UnixFSDirectory properties safely
}
-Optional
options: ExporterOptionsWhen entry
is a file or a raw
node, offset
and/or length
arguments can be passed to entry.content()
to return slices of data:
Optional
options: ExporterOptionsWhen entry
is a file or a raw
node, offset
and/or length
arguments can be passed to entry.content()
to return slices of data:
const length = 5
const data = new Uint8Array(length)
let offset = 0
for await (const chunk of entry.content({
offset: 0,
length
})) {
data.set(chunk, offset)
offset += chunk.length
}
// `data` contains the first 5 bytes of the file
return data
If entry
is a directory, passing offset
and/or length
to entry.content()
will limit the number of files returned from the directory.
const entries = []
for await (const entry of dir.content({
offset: 0,
length: 5
})) {
entries.push(entry)
}
// `entries` contains the first 5 files/directories in the directory
-Generated using TypeDoc
Generated using TypeDoc
Generated using TypeDoc
Generated using TypeDoc
Generated using TypeDoc
Generated using TypeDoc
Generated using TypeDoc
Generated using TypeDoc
Optional
pathOptional
unixfsGenerated using TypeDoc
Optional
pathOptional
unixfsGenerated using TypeDoc
Optional
modeOptional
mtimeOptional
originalOptional
pathGenerated using TypeDoc
Optional
modeOptional
mtimeOptional
originalOptional
pathGenerated using TypeDoc
Generated using TypeDoc
Generated using TypeDoc
Optional
modeOptional
mtimeOptional
originalOptional
pathGenerated using TypeDoc
Optional
modeOptional
mtimeOptional
originalOptional
pathGenerated using TypeDoc
Optional
modeOptional
mtimeOptional
pathGenerated using TypeDoc
Optional
modeOptional
mtimeOptional
pathGenerated using TypeDoc
Generated using TypeDoc
Generated using TypeDoc
Generated using TypeDoc
Generated using TypeDoc
Options to control the importer's behaviour
-Optional
blockHow many blocks to hash and write to the block store concurrently. For small +
Options to control the importer's behaviour
+Optional
blockHow many blocks to hash and write to the block store concurrently. For small numbers of large files this should be high (e.g. 50). Default: 50
-Optional
bufferThis option can be used to override the importer internals.
+Optional
bufferThis option can be used to override the importer internals.
This function should read Buffer
s from source
and persist them using blockstore.put
or similar
entry
is the { path, content }
entry, where entry.content
is an async
@@ -26,15 +26,15 @@
the properties { cid, unixfs, size }
where cid
is a [CID], unixfs
is a [UnixFS] entry and size
is a Number
that represents the serialized size of the [IPLD] node that holds the buffer data.
Values will be pulled from this generator in parallel - the amount of
parallelisation is controlled by the blockWriteConcurrency
option (default: 10)
Optional
chunkThis option can be used to override the importer internals.
+Optional
chunkThis option can be used to override the importer internals.
This function takes input from the content
field of imported entries.
It should transform them into Buffer
s, throwing an error if it cannot.
It should yield Buffer
objects constructed from the source
or throw an
Error
Optional
chunkerThe chunking strategy. See ./src/chunker/index.ts +
Optional
chunkerThe chunking strategy. See ./src/chunker/index.ts for available chunkers. Default: fixedSize
-Optional
cidthe CID version to use when storing the data. Default: 1
-Optional
dagThis option can be used to override the importer internals.
+Optional
cidthe CID version to use when storing the data. Default: 1
+Optional
dagThis option can be used to override the importer internals.
This function should read { path, content }
entries from source
and turn them
into DAGs
It should yield a function
that returns a Promise
that resolves to
@@ -42,32 +42,32 @@
is a UnixFS entry and node
is a DAGNode
.
Values will be pulled from this generator in parallel - the amount of parallelisation
is controlled by the fileImportConcurrency
option (default: 50)
Optional
fileHow many files to import concurrently. For large numbers of small files this +
Optional
fileHow many files to import concurrently. For large numbers of small files this should be high (e.g. 50). Default: 10
-Optional
layoutHow the DAG that represents files are created. See +
Optional
layoutHow the DAG that represents files are created. See ./src/layout/index.ts for available layouts. Default: balanced
-Optional
leafWhat type of UnixFS node leaves should be - can be 'file'
or 'raw'
+
Optional
leafWhat type of UnixFS node leaves should be - can be 'file'
or 'raw'
(ignored when rawLeaves
is true
).
This option exists to simulate kubo's trickle dag which uses a combination
of 'raw'
UnixFS leaves and reduceSingleLeafToSelf: false
.
For modern code the rawLeaves: true
option should be used instead so leaves
are plain Uint8Arrays without a UnixFS/Protobuf wrapper.
Optional
onOptional
rawWhen a file would span multiple DAGNodes, if this is true the leaf nodes +
Optional
onOptional
rawWhen 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. Default: true
Optional
reduceIf the file being imported is small enough to fit into one DAGNodes, store +
Optional
reduceIf the file being imported is small enough to fit into one DAGNodes, store the file data in the root node along with the UnixFS metadata instead of in a leaf node which would then require additional I/O to load. Default: true
-Optional
shardThe number of bits of a hash digest used at each level of sharding to +
Optional
shardThe number of bits of a hash digest used at each level of sharding to the child index. 2**shardFanoutBits will dictate the maximum number of children for any shard in the HAMT. Default: 8
-Optional
shardIf the serialized node is larger than this it might be converted to a HAMT +
Optional
shardIf the serialized node is larger than this it might be converted to a HAMT sharded directory. Default: 256KiB
-Optional
treeThis option can be used to override the importer internals.
+Optional
treeThis option can be used to override the importer internals.
This function should read { cid, path, unixfs, node }
entries from source
and
place them in a directory structure
It should yield an object with the properties { cid, path, unixfs, size }
where
cid
is a CID
, path
is a string, unixfs
is a UnixFS entry and size
is a Number
.
Optional
wrapIf true, all imported files and folders will be contained in a directory that +
Optional
wrapIf true, all imported files and folders will be contained in a directory that will correspond to the CID of the final entry yielded. Default: false
-Generated using TypeDoc
Generated using TypeDoc
Optional
originalOptional
pathOptional
unixfsGenerated using TypeDoc
Optional
originalOptional
pathOptional
unixfsGenerated using TypeDoc
Optional
originalOptional
pathOptional
unixfsGenerated using TypeDoc
Optional
originalOptional
pathOptional
unixfsGenerated using TypeDoc
Generated using TypeDoc
Generated using TypeDoc
Generated using TypeDoc
Generated using TypeDoc
Generated using TypeDoc
Generated using TypeDoc
This module contains the protobuf definition of the UnixFS data structure found at the root of all UnixFS DAGs.
+This module contains the protobuf definition of the UnixFS data structure found at the root of all UnixFS DAGs.
The UnixFS spec can be found in the ipfs/specs repository
const data = new UnixFS({ type: 'file' })
data.addBlockSize(256) // add the size of each block
data.addBlockSize(256)
// ...
@@ -36,8 +36,8 @@ const file = new Data({ type: 'file' })
file.mtime // undefined
Object.prototype.hasOwnProperty.call(file, 'mtime') // false
const dir = new Data({ type: 'dir', mtime: new Date() })
dir.mtime // { secs: Number, nsecs: Number }
-Generated using TypeDoc
Generated using TypeDoc
The UnixFS Exporter provides a means to read DAGs from a blockstore given a CID.
+The UnixFS Exporter provides a means to read DAGs from a blockstore given a CID.
// import a file and export it again
import { importer } from 'ipfs-unixfs-importer'
import { exporter } from 'ipfs-unixfs-exporter'
import { MemoryBlockstore } from 'blockstore-core/memory'
// Should contain the blocks we are trying to export
const blockstore = new MemoryBlockstore()
const files = []
for await (const file of importer([{
path: '/foo/bar.txt',
content: new Uint8Array([0, 1, 2, 3])
}], blockstore)) {
files.push(file)
}
console.info(files[0].cid) // Qmbaz
const entry = await exporter(files[0].cid, blockstore)
console.info(entry.cid) // Qmqux
console.info(entry.path) // Qmbaz/foo/bar.txt
console.info(entry.name) // bar.txt
console.info(entry.unixfs.fileSize()) // 4
// stream content from unixfs node
const size = entry.unixfs.fileSize()
const bytes = new Uint8Array(size)
let offset = 0
for await (const buf of entry.content()) {
bytes.set(buf, offset)
offset += chunk.length
}
console.info(bytes) // 0, 1, 2, 3
-Generated using TypeDoc
Generated using TypeDoc
Generated using TypeDoc
-JavaScript implementation of the UnixFs importer used by IPFS
Let's create a little directory to import:
+Let's create a little directory to import:
> cd /tmp
> mkdir foo
> echo 'hello' > foo/bar
> echo 'world' > foo/quux
And write the importing logic:
@@ -32,7 +47,7 @@Please be aware that all interactions related to this repo are subject to the IPFS Code of Conduct.
Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.
-Generated using TypeDoc
Generated using TypeDoc
Let's create a little directory to import:
+Let's create a little directory to import:
> cd /tmp
> mkdir foo
> echo 'hello' > foo/bar
> echo 'world' > foo/quux
And write the importing logic:
@@ -7,28 +7,28 @@When run, metadata about DAGNodes in the created tree is printed until the root:
{
cid: CID, // see https://github.com/multiformats/js-cid
path: 'tmp/foo/bar',
unixfs: UnixFS // see https://github.com/ipfs/js-ipfs-unixfs
}
{
cid: CID, // see https://github.com/multiformats/js-cid
path: 'tmp/foo/quxx',
unixfs: UnixFS // see https://github.com/ipfs/js-ipfs-unixfs
}
{
cid: CID, // see https://github.com/multiformats/js-cid
path: 'tmp/foo',
unixfs: UnixFS // see https://github.com/ipfs/js-ipfs-unixfs
}
{
cid: CID, // see https://github.com/multiformats/js-cid
path: 'tmp',
unixfs: UnixFS // see https://github.com/ipfs/js-ipfs-unixfs
}
-Generated using TypeDoc
Generated using TypeDoc
Layout functions allow customising the shape of final DAGs
+Layout functions allow customising the shape of final DAGs
https://dag.ipfs.tech can be used to explore different conigurations.
-Generated using TypeDoc
Generated using TypeDoc
Generated using TypeDoc
Generated using TypeDoc
Progress events emitted by the exporter
-Generated using TypeDoc
Progress events emitted by the exporter
+Generated using TypeDoc
A subset of the Blockstore interface that just contains the get +
A subset of the Blockstore interface that just contains the get method.
-Generated using TypeDoc
Generated using TypeDoc
A UnixFSEntry is a representation of the types of node that can be +
A UnixFSEntry is a representation of the types of node that can be encountered in a DAG.
-Generated using TypeDoc
Generated using TypeDoc
Generated using TypeDoc
Generated using TypeDoc
Generated using TypeDoc
Generated using TypeDoc
Generated using TypeDoc
Generated using TypeDoc
Generated using TypeDoc
Generated using TypeDoc
Generated using TypeDoc
Generated using TypeDoc
Generated using TypeDoc
Generated using TypeDoc
Generated using TypeDoc
Generated using TypeDoc
Generated using TypeDoc
Generated using TypeDoc
Generated using TypeDoc
Generated using TypeDoc
Generated using TypeDoc
Generated using TypeDoc
Returns
-0n
for directories ordata.length + sum(blockSizes)
for everything else