-
Notifications
You must be signed in to change notification settings - Fork 74
New Example: create and read ipfs files in browser #17
Comments
I am getting an error with it : fs.readFileSync is not a function. what to do? |
@carver any help will be appreciated. |
It's been a while since I've looked at this. Based on my fuzzy memory, there were some security issues preventing this from going live. The code above (untested at the time, and stale by a year now) was meant to be more of a reminder of where to start when writing a doc. It wasn't ready to be an example that people can use out of the box. I'm afraid I don't have time to dedicate to making the doc "production ready" right now. Getting it working will probably require talking to the ipfs team and/or digging deeper into the ipfs code. |
ok |
I've just created a working example based of this: ipfs-inactive/js-ipfs-http-client#315 |
@dignifiedquire I've tried your example but I encounter this issue: |
I think this error is due to the second check on the response in the display() function. I hope that there should be a replacement of "if(!res.readable)" at "if(res.readable)". Because if it is readable, it should not throw any error. Just give it a look as i didn't write the code, i am not very sure. |
@aniket-kumar thanks. Am I right to assume that the text I stored in IPFS (ghi) should be displayed in place of [ipfs content]? Currently, it displays Object object. |
@ColeMorton I think you have to use JSON.parse() for that. Otherwise you can run loop to check every key of the object. |
@aniket-kumar thanks, I found the answer: ipfs-inactive/js-ipfs-http-client#55.
Thanks @dignifiedquire |
@aniket-kumar, what was the solution to your problem for -> " |
When IPFS adds files in the browser where is the data written to? Browser memory or local storage and there's a fairly small limit? |
@JohnAllen by default it is written to IndexedDB, however, that can be changed as a repo configuration. |
@lindybrits I believe I answered your question through IRC at the time, but just for the record, the examples here should show you how to bundle js-ipfs-api for the browser https://github.com/ipfs/js-ipfs-api/tree/master/examples |
In case this helps someone else, the
|
Note to self. Something like:
Write this to index.js
Open http://localhost:8888/index.html
The text was updated successfully, but these errors were encountered: