A package that can automatically obtain the file suffix Install pip install filestream-y Use from filestream_y.FileStream_y import stream_type stream = stream_type(<file_bytes>) print(stream)