Page 2 of 2
Re: EASY.SQL.2025.09.01 (A lot of new stuff!)
Posted: Sat Sep 13, 2025 2:01 am
by srvet_claudio
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
);
Re: EASY.SQL.2025.09.01 (A lot of new stuff!)
Posted: Sat Sep 13, 2025 5:27 pm
by mol
I don't know how to transfer binary data to a postgresql server directly
Re: EASY.SQL.2025.09.01 (A lot of new stuff!)
Posted: Sat Sep 13, 2025 5:29 pm
by serge_girard
Marek, your code isn't working?
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
Re: EASY.SQL.2025.09.01 (A lot of new stuff!)
Posted: Sun Sep 14, 2025 8:52 am
by mol
My code is working, thanks for helping!
Re: EASY.SQL.2025.09.01 (A lot of new stuff!)
Posted: Sat Sep 20, 2025 4:32 pm
by franco
Hi Merek. If you remember I could never figure out Web servers or sql. I have worked around it all.
I have two programs using pictures. 1. motor rewinding 32 pictures per invoice. 2 Pos 8 pictures per invoice.
I create a folder in the programs folder called Photo. This is where the linking pictures are. Name invoice#.jpg.
I can take a picture with a tablet or cell phone and it puts it in my onedrive. The program is waiting for a picture to arrive.
When it arrives it copys it to the photo folder and then erases it from the onedrive. My problem was it was 2 to 3 megs, but
I then found I could resize it in the program and it ends up being 600 kb.
Not Sure if this has anything to do with what you are talking about here. I do find it takes a bit to download the picture to onedrive.
On another topic is it possible to use tables in a Web server. I still use local temporary indexes instead of sql. They seam to work fast.
I used to use foxpro`s sql but this works well for me. You once helped with web server but never had time to use it. Have more time now.
Re: EASY.SQL.2025.09.01 (A lot of new stuff!)
Posted: Sat Sep 20, 2025 4:44 pm
by franco
Another thought, I am sure you have tried. Could you not resize photo after it is saved in server.
Re: EASY.SQL.2025.09.01 (A lot of new stuff!)
Posted: Thu Sep 25, 2025 8:37 pm
by mol
I need to save pictures with original resolution. Jpg's are compressed be itself, so, compressing it has no sense.
I want to save it originally as it is, maybe another (not mine) application will need to read it