Intro
Installable via npm install --save ipfs-repo, it can also be used directly in the browser.
Quick Example
'use strict'
const Repo = require('ipfs-repo')
const repo = new Repo('/Users/awesome/.jsipfs')
repo.init({my: 'config'}, (err) => {
if (err) {
throw err
}
repo.open((err) => {
if (err) {
throw err
}
console.log('repo is ready')
})
})
There are more available, so take a look at the docs below for a full list. This documentation aims to be comprehensive, so if you feel anything is missing please create a GitHub issue for it.
Download
The source is available for download from GitHub. Alternatively, you can install using npm:
$ npm install --save ipfs-repo
You can then require() ipfs-repo as normal:
const ipfsRepo = require('ipfs-repo')
In the Browser
Ipfs-repo should work in any ES2015 environment out of the box.
Usage:
<script type="text/javascript" src="index.js"></script>
The portable versions of ipfs-repo, including index.js and index.min.js, are included in the /dist folder. Ipfs-repo can also be found on unkpkg.com under
has
Does the store contain block with this cid?
Parameters
cid: CID:callback: function (Error, bool):
Returns
void
IpfsRepo
IpfsRepo implements all required functionality to read and write to an ipfs repo.
Parameters
repoPath: any:options: any:
instance
IpfsRepo.prototype.init
init(config: Object, callback: function (Error)): voidInitialize a new repo.
Returns
void
IpfsRepo.prototype.open
open(callback: function (Error)): voidOpen the repo. If the repo is already open no action will be taken. If the repo is not initialized it will return an error.
Parameters
callback: function (Error):
Returns
void
IpfsRepo.prototype.close
close(callback: function (Error)): voidClose the repo and cleanup.
Parameters
callback: function (Error):
Returns
void