Use when developing node.js applications with IPFS.
ipfs-disperse is used to run common IPFS commands from node including: add, pin, unpin, and start daemon.
Either through cloning with git or by using npm:
npm install ipfs-disperse
Please install IPFS before installing ipfs-disperse from https://ipfs.io/docs/install/
const ipfs-disperse = require('ipfs-disperse');
disperse.ipfsAdd("file path").then(function (data) {
alert("file added correctly");
}).catch(function (error) {
alert("error");
});
disperse.publishHash("IPFS Hash").then(function (data) {
alert("Hash has been published!");
}).catch(function (error) {
alert("error");
});
disperse.addPin("IPFS Hash").then(function (data) {
alert("Hash has been pinned!");
}).catch(function (error) {
alert("error");
});
disperse.unPin("IPFS Hash").then(function (data) {
alert("Hash has been unpinned!");
}).catch(function (error) {
alert("error");
});