@metabin/share v0.0.2
Metabin Share
Advanced data sharing ultility
Installation
Metabin share can be used as a local npm module
npm install @metabin/share
Also it can be installed for command line usage.
npm install -g @metabin/share
Usage
Metabin-share connects to ipfs daemon runned on localhost. You can use either go version or js version of ipfs. Go here for details on installation.
After you install ipfs on your machine run it with the following command:
$ ipfs daemon --enable-pubsub-experiment
...or for js version of ipfs installed globally via npm:
$ jsipfs daemon --enable-pubsub-experiment
As a command line tool
To share some data use put command followed by list of meta .json files.
$ metabin put meta1.json folder/meta2.json
To get some data from the sharing space use get command followed by list of content identifiers (cids).
$ metabin get zdpuAufGD4jzjxTfLiJYSNPNpBTdfLaVjXZARCDk1fBYW5j7Y
As a javascript module
To share some data use metabinShare.put() command with a valid metabin object passed as a first argument.
import metabinShare from '@metabin/share'
// const metabinShare = require('@metabin/share')
// const { put } = require('@metabin/share')
const validMetaObj = {
"schema": {
"field": [[ "A", "B", "C" ]]
},
"data": {
"field": 1
}
}
const { validatorReports, cid } = metabinShare.put(validMetaObj)
console.log(cid)
// zdpuAufGD4jzjxTfLiJYSNPNpBTdfLaVjXZARCDk1fBYW5j7Y
console.log(validatorReports)
// [ { path: '/field', valid: true, message: undefined } ]To get some data from the sharing space use metabinShare.get() with a content identifier (cid) passed as a first argument.
import metabinShare from '@metabin/share'
// const metabinShare = require('@metabin/share')
// const { get } = require('@metabin/share')
const validCid = 'zdpuAufGD4jzjxTfLiJYSNPNpBTdfLaVjXZARCDk1fBYW5j7Y'
const { validatorReports, metaObj } = metabinShare.get(validCid)
console.log(metaObj)
/*
{
"schema": {
"field": [[ "A", "B", "C" ]]
},
"data": {
"field": 1
}
}
*/
console.log(validatorReports)
// [ { path: '/field', valid: true, message: undefined } ]License
MIT