Skip to content

Respect original filename when cached example files are downloaded#2145

Merged
freddyaboulton merged 2 commits into
mainfrom
2140-respect-cached-filenames-in-download
Sep 6, 2022
Merged

Respect original filename when cached example files are downloaded#2145
freddyaboulton merged 2 commits into
mainfrom
2140-respect-cached-filenames-in-download

Conversation

@freddyaboulton
Copy link
Copy Markdown
Collaborator

@freddyaboulton freddyaboulton commented Aug 31, 2022

Description

Fixes #2140

The downloaded filename is the same as what is returned from the prediction function now but you'll note that the extension for the file in the Model3D demo is messed up.

This is because when the output is cached, we return a base64 representation of the file as opposed to serving the file itself. The data streams for Model3D files have application/x-tgif and application/octet-stream mime types and I think Chrome can't guess the file extension for those mime types.

To get around this we'd have to serve the file for examples too but decided to hold off and hear other's thoughts on the matter.

Checklist:

  • I have performed a self-review of my own code
  • My code follows the style guidelines of this project
  • I have commented my code in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes

@github-actions
Copy link
Copy Markdown
Contributor

All the demos for this PR have been deployed at https://huggingface.co/spaces/gradio-pr-deploys/pr-2145-all-demos

@freddyaboulton freddyaboulton force-pushed the 2140-respect-cached-filenames-in-download branch from d84a38b to 732777d Compare August 31, 2022 18:49
@abidlabs
Copy link
Copy Markdown
Member

Just merged 3.2 in here so the tests pass

@freddyaboulton freddyaboulton force-pushed the 2140-respect-cached-filenames-in-download branch from c7725a4 to e434446 Compare August 31, 2022 20:04
@freddyaboulton freddyaboulton marked this pull request as ready for review August 31, 2022 20:34
@freddyaboulton freddyaboulton force-pushed the 2140-respect-cached-filenames-in-download branch from e26f9af to 1149020 Compare September 1, 2022 14:35
@abidlabs
Copy link
Copy Markdown
Member

abidlabs commented Sep 6, 2022

LGTM, but there is a deeper problem that you point out, which is the for cached file examples, we first serialize them to base64 (thereby losing the extension information), and then the browser has to convert them to a file for download. We really should avoid this, but for now, let's file an issue and take a look later @freddyaboulton?

@freddyaboulton
Copy link
Copy Markdown
Collaborator Author

@abidlabs Thanks for the review! Filed #2187

@freddyaboulton freddyaboulton merged commit 9b4bf62 into main Sep 6, 2022
@freddyaboulton freddyaboulton deleted the 2140-respect-cached-filenames-in-download branch September 6, 2022 14:41
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.

When caching the output of a file component in examples, the filename is not respected

2 participants