i have a fast api application where the dxf file is uploaded. It is passed to a function to read the contents. I have used read() method to read the file as bytes, then converted to string by using .decode(“utf-8”) and the converted it to string io object using io.StringIo. Finally this stringio object is passed as the argument to ezdxf.read(). But an error is thrown is ezdxf.lldxf.const.DXFStructureError: Invalid binary data near line: 7618.’ Please guide me to resolve this.

dxf_bytes=await upload_file.read()

Based on the error, I think you might want to just pass it as a binary file instead of decoding to a string?

dxf_bytes = await upload_file.read()
dxf_bytesio = io.BytesIO(dxf_bytes)
doc = ezdxf.read(dxf_bytesio)