jupyterlab-contrib / jupyterlab-filesystem-access

[Experimental] Browse local files using the non-standard File System Access API
https://jupyterlab-filesystem-access.readthedocs.io
BSD 3-Clause "New" or "Revised" License
31 stars 6 forks source link

Add support for base64 types #20

Closed martinRenou closed 2 years ago

martinRenou commented 2 years ago

Attempt to fix #17

The implementation I'm suggesting here looks for the mimetype:

    if (file.type === 'image/png') {
      format = 'base64';
    } else {
      format = 'text';
    }

For comparison, jupyter_server seems to try to encode the file content to utf8, if that fails it falls back to base64: https://github.com/jupyter-server/jupyter_server/blob/25ec3ed0dad617a4388db865e9c1a585e54c0b7c/jupyter_server/services/contents/fileio.py#L300-L327

I wonder if we could implement something similar in JavaScript

https://user-images.githubusercontent.com/21197331/162987570-c8084882-9176-4bdb-a3bb-4c969830c60a.mp4

jtpio commented 2 years ago

Thanks!