Can't understand how load binary text instead files

Hi,

I want to create an assistant by passing it not the file directly (the file path) but a binary that I get from another source.
For example:

%PDF-1.7
%����
1 0 obj
<</Type/Catalog/Pages 2 0 R/Lang(it) /StructTreeRoot 99 0 R/Mar

I tried something like this:

file = client.files.create(
                file=("filename.pdf", io.BytesIO(text), "file"),
                purpose="assistants",
           )

It doesn’t found answer like when i upload directly the file with

file = client.files.create(
                file=open(filename, "rb"),
                purpose="assistants",
           )

I would like to load correctly these type of “text”