Saving Autocad File (.dwg) as binary in database

Hi everyone,
ist it possible to read an Autocad file (.dwg) and save it binary in a database?

If it’s saved in the database how can i restore and open it in the Autocad app?

“in database” is rough, what system?

the databasecolumn class have a property BlobValue.
the field in database could be blob or binary.
postgres database class have extra methods.
read/write binary with BinaryStream
access file with FolderItem.
see also FolderItem.Open
“If the FolderItem is a document, the document is opened using its default app.”

you have to read the file data into memory/variable and then assign it to a database field.

Thanks Markus,
the dataatabase is MySql.
The first question for me is how to read/write the Binary Stream with Xojo independend from the database system.
I tried the Binary Stream sample code from the docs but it doesn’t work. With any file format i get an error, only with .txt files i can handle it, but the result is the text written backwards.

So if it doesn’t even work with a textfile i can imagine that it can’t work with a .dwg Autocad file.

should be something like this example (untested)

Var f As FolderItem
Var stream As BinaryStream
Var data As String
f = FolderItem.ShowOpenFileDialog("")
If f <> Nil Then
  stream = BinaryStream.Open(f, True)
   data = stream.Read(stream.Length)
End If

Thanks Markus, but how can i “restore” the file?
I still don’t know how to save it binary and than read again and open it in the default app.

I can find examples for picture files, but not for other filetypes…

you would open a file to output data into binary stream.
how to open a file by its extension in mentioned above.

all files are binary data, just bytes.

The file type really doesn’t matter. Data is data.