Hi Marek,
Have you tried saving the image directly as a BLOB data?
Like this:
CREATE TABLE Image (
id INT AUTO_INCREMENT PRIMARY KEY,
name VARCHAR(255),
imageData LONGBLOB
);
EASY.SQL.2025.09.01 (A lot of new stuff!)
Moderator: Rathinagiri
- srvet_claudio
- Posts: 2223
- Joined: Thu Feb 25, 2010 8:43 pm
- Location: Uruguay
- Contact:
Re: EASY.SQL.2025.09.01 (A lot of new stuff!)
I don't know how to transfer binary data to a postgresql server directly
- serge_girard
- Posts: 3333
- Joined: Sun Nov 25, 2012 2:44 pm
- DBs Used: 1 MySQL - MariaDB
2 DBF - Location: Belgium
- Contact:
Re: EASY.SQL.2025.09.01 (A lot of new stuff!)
Marek, your code isn't working?
Looks good to me:
Looks good to me:
Code: Select all
cContent := hb_Base64Encode( hb_memoread("place.jpg") )
cSQL := "INSERT INTO images (Zawartosc) VALUES (decode('" + cContent + "','base64' ) ) RETURNING Image_ID"
aTmp := pgSelectQuery(oServerMaster,cSQL, .t.)
if empty(aTmp)
MsgDebug("Error!")
return
endif
// retriving file from server
nId := aTmp[1,1]
cSQL := "SELECT encode(Zawartosc::ByteA, 'base64') FROM images WHERE image_id = " + hb_ntos(nId)
aTmp := pgSelectQuery(oServerMaster,cSQL, .f.)
if !empty(aTmp)
hb_memowrit('Odpowiedz.jpg', hb_Base64Decode(aTmp[1][1]))
execute file 'odpowiedz.jpg'
endif
There's nothing you can do that can't be done...