Js-ipfs in-browser persistent pins

js-ipfs
#1

Hey, is there a way to pin a hash in the browser (presumably to localStorage) so that it persists between refreshes?

I’d like users to be able to come back to my site and have access to all the stuff they saved before even if no one else on the network has cached it.

I know this is supposed to happen already, but if I pin an example hash (and confirm success with pin.ls), disconnect from the internet, and refresh the page (localhost), I can no longer cat that hash. (No, it’s not because I’m doing a hard refresh, though that does make this fail as well.)

#2

Never mind, I’m pretty sure this is a bug and filed an issue here: https://github.com/ipfs/js-ipfs/issues/2045

#3

Alan Shaw said:

You’re using a different repo each time: repo: String(Math.random() + Date.now())
Try setting that to a static string instead and it should work.

Hope that helps

2 Likes