Skip to content

Commit df6f03a

Browse files
committed
add raise error for invalid type in detect_file_source
1 parent 1546ecc commit df6f03a

1 file changed

Lines changed: 4 additions & 1 deletion

File tree

pyrogram/utils.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -729,7 +729,10 @@ def detect_file_source(file: Union[str, BinaryIO]) -> FileSource:
729729
return FileSource.URL
730730
else:
731731
return FileSource.FILE_ID
732-
return FileSource.BYTES_IO
732+
733+
if isinstance(file, BytesIO):
734+
return FileSource.BYTES_IO
735+
raise ValueError("file must be a file path, URL, file ID, or BytesIO object")
733736

734737

735738
async def prepare_media_for_upload(

0 commit comments

Comments
 (0)