This page creates an IPFS node in your browser and drops it into the global Javascript namespace as node. Open the console to play around with it.
Note that opening two tabs of this page in the same browser won't work well, because they will share node configuration. You'll end up trying to run two instances of the same node, with the same private key and identity, which is a Bad Idea.
Try adding a new file:
const { Buffer } = Ipfs
node.add(new Buffer('Hello world!'), (err, filesAdded) => {
if (err) {
return console.error('Error - ipfs add', err, res)
}
filesAdded.forEach((file) => console.log('successfully stored', file.hash))
})
You can cat that same file. If you used the exact same string as above ('Hello world!') you should have an hash like this: 'QmQzCQn4puG4qu8PVysxZmscmQ5vT1ZXpqo7f58Uh9QfyY'
node.cat('QmQzCQn4puG4qu8PVysxZmscmQ5vT1ZXpqo7f58Uh9QfyY', function (err, data) {
if (err) {
return console.error('Error - ipfs files cat', err, res)
}
console.log(data.toString())
})