Skip to content
This repository has been archived by the owner on Dec 26, 2019. It is now read-only.

Support for binary file transfer in ipywidgets 7 #20

Open
jasongrout opened this issue Jul 28, 2017 · 7 comments
Open

Support for binary file transfer in ipywidgets 7 #20

jasongrout opened this issue Jul 28, 2017 · 7 comments

Comments

@jasongrout
Copy link

jasongrout commented Jul 28, 2017

In ipywidgets 7.0, attributes can be binary and will then be synced with binary messages. That may make a big difference for large files (instead of base64 encoding them).

Also, FYI, @draperjames was looking into making a standard file upload widget in the base ipywidgets package (jupyter-widgets/ipywidgets#1542). Would you be willing to collaborate on such a standard widget?

Thanks for writing this!

@peteut
Copy link
Owner

peteut commented Jul 28, 2017

+1 for a standard widget, that would be nice! Binary upload should be easy to support, as there is FileReader#readAsBinaryString.

@peteut
Copy link
Owner

peteut commented Jul 28, 2017

@jasongrout I just realised that FileReader#readAsBinaryString is non-standard:
Note that this method is now deprecated as per the 12 July 2012 Working Draft from the W3C.

@jasongrout
Copy link
Author

jasongrout commented Jul 28, 2017

You'll want to use https://developer.mozilla.org/en-US/docs/Web/API/FileReader/readAsArrayBuffer - ArrayBuffers are what ipywidgets recognizes as a binary state value.

@draperjames
Copy link
Contributor

@jasongrout looks like a winner to me. It even works on Edge. The only thing is the status is listed as working draft should we expect drastic changes in the future or will it stay more or less as is?

@jasongrout
Copy link
Author

Good question. We can update the code if it does change.

@jasongrout
Copy link
Author

But it seems to have been implemented for years - it sounds pretty safe.

@hugulas
Copy link

hugulas commented Oct 19, 2018

@peteut I modified the code to support binary file. And I plan to contribute the patch back. Would you mind to review the patch?If yes, I will need to go through my company's open source process first. Thanks.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants