Skip to content

Conversation

@cpsievert
Copy link
Collaborator

Closes #240
Closes #330

Also adds output_table and render.table to the API reference

@cpsievert cpsievert requested a review from wch September 29, 2022 23:05
Comment on lines 56 to 58
with open(f, "rb") as x:
fc = base64.b64encode(x.read()).decode("utf-8")
code += f"\n\n## file: {os.path.basename(f)}\n## type: binary\n{fc}"
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think this should encode all files as binary. Text files shouldn't be base64 encoded -- that will work, but it'll make the file non-editable in the editor, and the content will also not be viewable.

Here's some code I used in shinylive to attempt reading as text, and if that fails, read as binary. It would make sense to do something similar here.
https://github.com/rstudio/py-shinylive/blob/486f9f9f7f54cb129b95c0122716990a40d66ed3/shinylive/_app_json.py#L73-L82

Copy link
Collaborator

@wch wch left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One issue here: the files should only be encoded as binary if they're actually binary files. Otherwise, looks good!

@wch wch force-pushed the add-example-files branch from 0aeacd2 to 3c43cd0 Compare October 28, 2022 19:19
@wch wch merged commit 5e4ebda into main Oct 28, 2022
@wch wch deleted the add-example-files branch October 28, 2022 19:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

API Docs: reactive.file_reader example is broken output_image example is broken

3 participants