[Gambas-user] Q:how to save a file.png into Postgresql
rterry at ...1946...
Sun Aug 31 03:10:49 CEST 2008
> Did you look at the "PictureDatabase" example? It stores images files from
> disk into a database, and retrieves them.
Thanks, yes I've done that overnight since your suggestion, and now have this
My gambas code goes something like this and I've selected the png file to load
which has been passed to this routine as ImagePath.
Public sub Save_Image(ImagePath as string)
Dim img As Image
Dim pictureData As String
Dim sql As String
img = Image.Load(ImagePath) ' Save temp image as png file
tempFile = Temp() & ".png"
pictureData = File.Load(tempFile) 'reload as a string
At this point the pictureData string seems to be ok.
I Then tried writing to the database:
sql = "insert into temp_image(piccie)"
sql = sql & pictureData & "$$)"
and got back this message:
Query failed:ERROR: invalid byte sequence for encoding "UTF8":0x89 HINT: This
error can also happen if the byte sequence does not match the encoding
expected by the server, which is controlled by "client_encoding"
Spent a couple of hours trawling the postgres help and looking up
client-encoding, pg_types etc etc, but with my limited brain power I got
More information about the User