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

gr.File should add .html extension to URLs if possible #9959

Open
1 task done
JohnDuncanScott opened this issue Nov 14, 2024 · 1 comment
Open
1 task done

gr.File should add .html extension to URLs if possible #9959

JohnDuncanScott opened this issue Nov 14, 2024 · 1 comment
Labels
enhancement New feature or request needs designing The proposed feature needs to be discussed and designed before being implemented

Comments

@JohnDuncanScott
Copy link

Describe the bug

When using gr.File, the file uploaded keeps its extension. However, when using a URL like https://liquipedia.net/starcraft2/Adept, the file saved in the cache has no extension. This is technically correct. However, since it's HTML being downloaded, it should really save with the .html extension (equivalent to right-click and Save As in the browser). This makes it easier for a user to identify where it came from and also makes it easier for file type detection (avoiding the need for things like libmagic). Maybe it could just be a "default_web_extension" option that the user sets in the control.

The data source is lost when the upload happens (probably for security reasons?), so once a file has been downloaded to cache, you can't tell what it was originally or where it came from. The workaround would be to assume no extension means HTML, but that's a little error prone too.

Have you searched existing issues? 🔎

  • I have searched and found no existing issues

Reproduction

Just use gr.File to upload a URL by pasting a URL into the File Explorer pop-up that appears when clicking Upload.

Screenshot

No response

Logs

No response

System Info

gradio==5.4.0

Severity

I can work around it

@JohnDuncanScott JohnDuncanScott added the bug Something isn't working label Nov 14, 2024
@abidlabs
Copy link
Member

We cannot make the assumption that that a url without extensions is an html file, e.g. https://api.github.com/users/octocat returns a JSON for example. A default_web_extension seems too fine-grained imo to add to the component. Open to other suggestions, but another option would be to create a custom component for your use case! https://www.gradio.app/guides/five-minute-guide, and we're happy to help.

@abidlabs abidlabs added needs designing The proposed feature needs to be discussed and designed before being implemented enhancement New feature or request and removed bug Something isn't working labels Nov 16, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request needs designing The proposed feature needs to be discussed and designed before being implemented
Projects
None yet
Development

No branches or pull requests

2 participants