Skip to content

Conversation

@majiayu000
Copy link
Contributor

Summary

  • Make WebP file extension check case-insensitive in get_mimetype()
  • Make VTT file extension check case-insensitive as well
  • Add test cases for case-insensitive MIME type detection

Root Cause

The get_mimetype() function was using case-sensitive string matching (filename.endswith(".webp")), which caused files with uppercase extensions like photo.WEBP to fall through to mimetypes.guess_type(). On some systems (especially Windows), this could return None for WebP files, causing validation to fail with "Invalid file type" error.

Test plan

  • Upload a .webp file - should work
  • Upload a .WEBP file - should now work (previously failed)
  • Upload a .WebP file - should work
  • Run pytest client/python/test/test_utils.py::test_get_mimetype -v
  • Run pytest client/python/test/test_utils.py::test_is_valid_file_type -v

Fixes #12036

The get_mimetype function was checking file extensions in a case-sensitive
manner, causing files like "photo.WEBP" to fail validation when used with
file_types=['image'].

This fix makes the extension checks case-insensitive for .webp and .vtt files.

Fixes gradio-app#12036

Signed-off-by: majiayu000 <[email protected]>
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.

Support webp files for image components

1 participant