Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for base64 types #20

Merged
merged 1 commit into from Apr 14, 2022

Conversation

martinRenou
Copy link
Member

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

pngs.mp4

@martinRenou martinRenou marked this pull request as ready for review April 13, 2022 08:18
@jtpio
Copy link
Member

jtpio commented Apr 14, 2022

Thanks!

@jtpio jtpio merged commit 42d34a6 into jupyterlab-contrib:main Apr 14, 2022
@jtpio jtpio added the enhancement New feature or request label Apr 14, 2022
@martinRenou martinRenou deleted the fix_binary_files_open branch April 14, 2022 07:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Opening binary files fails
2 participants