FileInput widget string format

Hi,
I’m playing around with the new FileInput widget in the 1.3.0rc2 release and struggling to figure out what to do with the imported data.

Essentially, I import a file, lets say a json file, and fileinput.file == something like:
data:application/json;base64,ewogICAgInBlcnNvbiI6IHsKICAgICAgICAiYWdlIjogMjIKICAgIH0KfQo=

I understand that the second part is the base64 encoded string but my question basically is: is there some obvious library or command I’m missing that I should be using to split this up or should I just write a simple parser to do it.

It seems that the panel widget that this one came from had 2 attributes, value(bytes) and mime_type(str) whereas the bokeh version has this combined string.

I am spectacularly overthinking this and should just split by the comma?

Thanks!

Scratch that, looks like you just have to do the parsing, described a bit in the docs for FileReader here

On a related note I might be sending in a pull request as I extended the widget to also return the filename as that was something I needed to get at, which would be exciting as it would be my first contribution to a public project!

Anyway, I’ve opened an issue on github for this now [FEATURE] Extend FileInput to return filename and make output clearer · Issue #9099 · bokeh/bokeh · GitHub

1 Like