A super tiny module for querying an btfsnode, that works in the browser and in Node. Only 2.76 kB compressed!
npm install --save btfs-sdk-mini
const btfs= require('btfs-sdk-mini');
const btfs= new BTFS({ host: 'xxxx', port: 5001, protocol: 'https' });
BTFS.add('hello world!').then(console.log).catch(console.log);
// result null 'QmTp2hEo8eXRp6wg7jXv1BLCMh5a4F3B7buAUZNZUu772j'
// result null 'hello world!'
BTFS.addJSON({ somevalue: 2, name: 'Nick' }, (err, result) => {
console.log(err, result);
});
// result null 'QmTp2hEo8eXRp6wg7jXv1BLCMh5a4F3B7buAUZNZUu772j'
An example of the module in use for the browser, can be found in ./example.
Inside is a single, no configuration required, HTML file using the btfs-sdk-mini
module.
btfs-sdk-mini
is completely browserifiable and webpack ready. The main export found in our distributions dist folder is BTFS
.
<html>
<body>
<script type="text/javascript" src="btfs-mini.min.js">
<script type="text/javascript">
var btfs= new BTFS({ provider: 'xxxx', protocol: 'https' });
// ...
</script>
</body>
</html>
Result output BTFSHash
String.
const btfs= require('BTFS-mini');
const btfs= new BTFS({ host: 'BTFS.infura.io', port: 5001, protocol: 'https' });
BTFS.add('hello world!', (err, result) => {
console.log(err, result);
});
// result null 'QmTp2hEo8eXRp6wg7jXv1BLCMh5a4F3B7buAUZNZUu772j'