• The importer creates UnixFS DAGs and stores the blocks that make them up in the passed blockstore.

    Parameters

    Returns AsyncGenerator<ImportResult, void, unknown>

    Example

    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(), ... }
    }