-
Notifications
You must be signed in to change notification settings - Fork 296
expose Buffer #53
expose Buffer #53
Conversation
|
@diasdavid will know better than me how to handle this |
|
It is a pity that both Buffers are called Buffers and don't have the implementation. Since this is not a common practice and also something not so usual to do in Browser applications, I suggest strongly that it has to be documented in the README and in case a user calls the function with a normal Browser Buffer obj, we should throw an error an point to the link in the README that explains that scenario. One other suggestion, which I believe it would be more clean, but at the same time, less convenient, is instead of exposing the buffer-browserify through self, invite people to use https://github.com/feross/buffer, which makes a very good job explaining the differences, making this step a 'buy in' from developers, ensuring that everyone knows the differences and also that they understand this 'special' Buffer can be used for scenarios than just the node-ipfs-api. |
|
We could also maybe change the default behavior of interpreting strings as filenames, and explicitly require Vinyl files, this way we could simply add JSON.stringify(object), without any extra headache. I'm not getting ipfs object add to work with Buffer included from either npm browser-buffer or buffer, at least not in combination with webcomponents. |
|
For now, i would think that exposing Buffer is not the worst way to go. It works reliably, even in webcomponents. |
|
Ok :) just add some documentation to it as other people will try to understand why their browser-buffers aren't working. |
no, that changes the interface. we promise that: all work the same: adds the file addressed by |
|
Oh :(, no documentation added to the README? |
|
Probably worth pushing out an NPM release for this, it's quite useful. |
|
@harlantwood you are totally right. Pushed 2.3.1 tag to npm https://github.com/ipfs/node-ipfs-api/releases/tag/v2.3.1 |
|
@diasdavid pushed 2.3.2, i think you forgot to run npm run build before! |
In order to make add work in the browser with the standalone browser, we need to access the Buffer object, it seems importing the browser-buffer as standalone trips up vinyl somehow.
This is not ideal, but unless we can find a way to make adding files from buffers really portable, it seems ok.
The three cases are: