def _magic_get_file_type(f, _): file_type = magic.from_buffer(f.read(1024), mime=True) f.seek(0) return maybe_decode(file_type)