• 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.

    Parameters

    Returns Promise<ImportResult>

    Example

    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)