binary files i.e. PDF

I’m wondering if there is a way to save any filetype as a binary file in a database
I’m creating a repository for my user community.
There’s a variety of file types that I want to save i.e PDF, jpeg, guitar pro files (.gpx), movie(.mov, .mp4) and others.
I’ve created a field for the name (including the extention i.e. “MyFirstTab.gpx”) and a longblob field for the file.
The only examples I could find was for text and pictures.

I’m after code that could create a string and code that would extract the string as save it as the file name…
is that how it works?

don’t worry - I found SQLiteblob on the examples

Actually - i didn’t get everything I needed as sqlite is not mysql (which is what I’m working with).
So - i turn a file into a binary file like this?
dlfiles(0-2) are binary streams
dltext(0-2) are textfields with the name
both are global

Dim file As FolderItem file = GetOpenFolderItem("") if file<>nil then dlfiles(filenumber) = BinaryStream.Open(file, False) DLtext(filenumber).text=file.Name End If

now, when I want to stick that in my database as a blob, i can’t use this SQlite stuff because it doesn’t want to work

so would I save it like this?

Dim row As New DatabaseRecord i=0 row.BlobColumn("dl1")=dlfiles(0) db.InsertRecord("mytable", row)

or using a recordset

rs = DB.SQLSelect("Select * from mytable where name='"+b+ "'") rs.edit rs.field("dl1").picturevalue=dlfiles(0) update

Hi Sean

I would be tempted to set the dl0-2 columns up as text data type and then encodebase64 the binary data. It’s not as efficient as a binary blob, but if you use the mysql command line it doesn’t drive this mad with unprintable characters if you happen to select * from which I do all the time. You can then decodebase64 to return the data back to binary.

The biggest problem you may run into is the lack of spooling of your data. Xojo put some work into SQLite so binary data would spool to the blob using less runtime memory.



I’ll get to see the day after tomorow - See you at the Auckland meet!