This repository was archived by the owner on Mar 10, 2020. It is now read-only.
This repository was archived by the owner on Mar 10, 2020. It is now read-only.
Trouble with base64 encoded buffers via browserified ipfsApi #55
Closed
Description
Looking up a base64 encoded buffer works fine with the node ipfs-api module. In the browser, it appears there's a problem converting it to a string from Uint8Array. Here is some code that encounters this
var gifData = 'R0lGODlhAQABAIAAAAUEBAAAACwAAAAAAQABAAACAkQBADs=';
ipfsApi.add(new Buffer(gifData, 'base64'), function(err, ipfsArr) {
if (err) throw err;
ipfsApi.cat(ipfsArr[0].Hash, function(err, blobStr) {
if (err) throw err;
console.log('equal:', Buffer(blobStr, 'ascii').toString('base64') === gifData); // false
});
});
This change -- [https://github.com/ckeenan/node-ipfs-api/commit/0a9290a17e970b8a447cd0ba4b3a202693a1dcb5] -- resolves it, but unsure if best solution