MDIP IPFS lib
npm install @mdip/ipfsMDIP utilities for integrating with IPFS.
``bash`
npm install @mdip/ipfs
`js
// Import using subpaths
import HeliaClient from '@mdip/ipfs/helia';
// Non-subpath import
import { HeliaClient } from '@mdip/ipfs';
const ipfs = new HeliaClient();
await ipfs.start();
const data = { data: 'whatever' };
const cid = await ipfs.addJSON(data);
const retrieve = await ipfs.getJSON(cid); // retrieve == data
await ipfs.stop();
`
The static factory method create can be used to create and start an IPFS instance:
`js`
const ipfs = await HeliaClient.create();
Passing datadir in options to start or create will persist the data to the specified folder.
`js`
const ipfs = await HeliaClient.create({ datadir: 'data/ipfs' });
Starting IPFS in minimal mode avoids starting a Helia IPFS server.add
Only works to generate CIDs. Nothing is persisted so get always throws a NotConnectedError.
`js``
const ipfs = await HeliaClient.create({ minimal: true });