diff --git a/.changeset/thick-teeth-crash.md b/.changeset/thick-teeth-crash.md new file mode 100644 index 0000000000..f50b67d455 --- /dev/null +++ b/.changeset/thick-teeth-crash.md @@ -0,0 +1,6 @@ +--- +"gradio": patch +"gradio_client": patch +--- + +fix:Fix: `file_types` checking bug diff --git a/client/python/gradio_client/utils.py b/client/python/gradio_client/utils.py index e49648afe7..10fe5ffe48 100644 --- a/client/python/gradio_client/utils.py +++ b/client/python/gradio_client/utils.py @@ -689,17 +689,15 @@ def get_extension(encoding: str) -> str | None: def is_valid_file(file_path: str, file_types: list[str]) -> bool: mime_type = get_mimetype(file_path) - if mime_type is None: - return False for file_type in file_types: if file_type == "file": return True if file_type.startswith("."): file_type = file_type.lstrip(".").lower() - mime_type_split = mime_type.lower().split("/") - if file_type == mime_type_split[1]: + file_ext = Path(file_path).suffix.lstrip(".").lower() + if file_type == file_ext: return True - elif mime_type.startswith(f"{file_type}/"): + elif mime_type is not None and mime_type.startswith(f"{file_type}/"): return True return False