-
Notifications
You must be signed in to change notification settings - Fork 298
add file does not work in browser (TypeError: target._set is not a function) #344
Comments
@nycoliver does https://github.com/ipfs/js-ipfs-api/tree/master/examples/browser-add work for you? If so, could you create an example in the example folders with your experiment so that we can easily replicate it? |
browser-add does not work for me. In master branch code throws The second error is due to js-ipfs-api and webpack incompatibility, as discussed in #335. I worked around this issue by importing ipfs-api and feross/buffer in script tags and skipping the webpack bundle step. With this workaround the text data successfully adds to ipfs but adding a file with the same code throws I opened a pull request with an example, please let me know if I can do anything else to help. |
Bug Update: Also ran into this trying to add buffer arrays to go-ipfs through js-ipfs-api in the browser. I get I put a fixed-sized-chunker on the buffer before
error
no eror however i'm able to buffer a bunch of zeors with |
As a work around to this you can pass a stream to I used Max Ogden's filereader stream to do this https://github.com/maxogden/filereader-stream e.g.
Hope this helps! |
Upon closer inspection this appears to be a problem with the buffer library, not ipfs. Not sure how we missed that... My example works fine if I webpack the buffers but keep ifps in a script tag. |
See https://github.com/nycoliver/js-ipfs-api/tree/fixes-browser-add/examples/browser-add-file for a working example. |
I just updated the example on |
Same code as examples/browser-add but adding a file instead of text. It works with text but when adding a file I get
index.js:1281 Uncaught TypeError: target._set is not a function
Maybe I am incorrectly forming the buffer? But even the files add code from ipfs-webui throws the same error.
index.html
index.js
The text was updated successfully, but these errors were encountered: