Reputation: 525
I have javascript app (ReactJs) which will run as an android hybrid app on mobile devices. I do not want to run full IPFS node on a mobile device, because it will consume a lot of its memory and energy. How can I connect my app to IPFS then?
I saw https://github.com/ipfs/js-ipfs-api#importing-the-module-and-usage, but it does not look usable for a mobile device again as it runs as a separated service.
Probably I have to connect to some IPFS node at the internet through IPFS API (https://ipfs.io/docs/api/), however is there a way to discover running nodes on the runtime and also to choose the fastest/closest one?
Upvotes: 18
Views: 5475
Reputation: 561
My experience, at least so far, is that there aren't really any good wrappers for IPFS, in any language. At least, not yet. But that's okay, because it's really simple to use. Just remember that it returns hashes in the headers when you add a file, not in the response body like you might expect. That really screwed me up. Other than that, there's nothing to it.
As far as not needing to run it... you really should run your own ipfs node. It's the only way to guarantee that your content will remain available when people want it. The cache life on IPFS seems to be about 8 hours, though, which is pretty amazing, but it's no substitute for actually being part of the network.
That said, you might be able to find public nodes that are writable. You'll have to do a google search for that, but I'm absolutely certain they're out there.
You might also want to look at channels like Steemit for people who are actively working on IPFS projects. I've had good luck there. A lot of answers about IPFS, Swarm, Web3, and Dapps in general.
Oh, and to test if a node is writeable, try this:
<form action="http://[domain_name]:[port_number]/ipfs/api/v0/add" enctype="multipart/form-data" method="post">
<input type="file" name="image" accept="image/*"/>
<input type="submit"/>
</form>
Good Luck!
Upvotes: 6
Reputation: 1832
You have a couple of options here:
js-ipfs
node instance when you need it and garbage collect it afterward.Are you developing a PWA? js-ipfs
works well on Chrome in Android phones, check https://github.com/ipfs/js-ipfs/tree/master/examples to learn how to get started.
Upvotes: 8