Home

Awesome

ipfs-blob-store

standard-readme compliant Dependency Status js-standard-style npm

An abstract-blob-store compatible implementation built using IPFS as the storage backend

Implements the abstract-blob-store, using IPFS for storage.

Install

npm install ipfs-blob-store

Usage

ipfs-blob-store uses the IPFS Files API to create the abstraction of a mutable filesystem over snapshots of Merkle DAGs (per mutation). You'll need to use the Files API directly to get the /ipfs/Qm... address of the filesystem root so that other IPFS nodes can retrieve it.

It requires an IPFS node to run - you can either specify a host/port combination to connect to a remote daemon, pass an instance of ipfs or nothing at all to have the blob store manage it's own IPFS node.

Self-managed IPFS node

const ipfsBlobStore = require('ipfs-blob-store')

const store = await ipfsBlobStore()

store.exists('/my-file.txt', (error, exists) => {
  // ...
})

Pre-configured IPFS node

const ipfsBlobStore = require('ipfs-blob-store')
const IPFS = require('ipfs')

const node = new IPFS({
  // some config here
})

node.once('ready', () => {
  const store = await ipfsBlobStore({
    ipfs: node
  })

  store.exists('/my-file.txt', (error, exists) => {
    // ...
  })
})

Remote IPFS daemon

const ipfsBlobStore = require('ipfs-blob-store')

const store = await ipfsBlobStore({
  host: '127.0.0.1',
  port: 5001
})

store.exists('/my-file.txt', (error, exists) => {
  // ...
})

Options

var options = {
  ipfs: null, // an instance of ipfs or ipfs-api
  port: 5001,   // default value
  host: '127.0.0.1', // default value
  baseDir: '/', // default value
  flush: true  // default value
}

const store = await ipfsBlobStore(options)

API

See abstract-blob-store for the blob store API.

Contribute

Feel free to join in. All welcome. Open an issue!

This repository falls under the IPFS Code of Conduct.

Want to hack on IPFS?

License

MIT