Skip to content

Commit

Permalink
Merge branch 'main' into main
Browse files Browse the repository at this point in the history
  • Loading branch information
abidlabs authored Oct 15, 2024
2 parents 5b26340 + a25a26e commit 5e9a1ef
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 5 deletions.
6 changes: 6 additions & 0 deletions .changeset/thick-teeth-crash.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
"gradio": patch
"gradio_client": patch
---

fix:Fix: `file_types` checking bug
8 changes: 3 additions & 5 deletions client/python/gradio_client/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down

0 comments on commit 5e9a1ef

Please sign in to comment.