Two part question:
let’s say i’ve added a file with a hash QmPChd2hVbrJ6bfo3WBcTW4iZnpHm8TEzWkLHmLpXhF68A
is it more reliable to display the file in a browser by converting the hash back into a buffer like this?
const fileBuffer = await node.cat(‘QmPChd2hVbrJ6bfo3WBcTW4iZnpHm8TEzWkLHmLpXhF68A’)
console.log(‘Added file contents:’, fileBuffer.toString())
//do something to display this data in web page
Or is embedding a public gateway in a web page like this reliable:
https://ipfs.io/ipfs/QmPChd2hVbrJ6bfo3WBcTW4iZnpHm8TEzWkLHmLpXhF68A
my concern is for a larger file or one that isn’t pinned - the public gateway will not be reliable and it is “safer” to convert the hash back to buffer and handle displaying it in a web page with the buffer data.
Second question:
when I use the cat method on a hash it returns [object object] but I am expecting a string. Is there a more up to date example of using cat method with js-ipfs?