EASY.SQL.2025.09.01 (A lot of new stuff!)

HMG Samples and Enhancements

Moderator: Rathinagiri

User avatar
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!)

Post 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
);
Best regards.
Dr. Claudio Soto
(from Uruguay)
http://srvet.blogspot.com
User avatar
mol
Posts: 3799
Joined: Thu Sep 11, 2008 5:31 am
Location: Myszków, Poland
Contact:

Re: EASY.SQL.2025.09.01 (A lot of new stuff!)

Post by mol »

I don't know how to transfer binary data to a postgresql server directly
User avatar
serge_girard
Posts: 3336
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!)

Post 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

There's nothing you can do that can't be done...
franco
Posts: 887
Joined: Sat Nov 02, 2013 5:42 am
DBs Used: DBF
Location: Canada

Re: EASY.SQL.2025.09.01 (A lot of new stuff!)

Post 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.
All The Best,
Franco
Canada
franco
Posts: 887
Joined: Sat Nov 02, 2013 5:42 am
DBs Used: DBF
Location: Canada

Re: EASY.SQL.2025.09.01 (A lot of new stuff!)

Post by franco »

Another thought, I am sure you have tried. Could you not resize photo after it is saved in server.
All The Best,
Franco
Canada
User avatar
mol
Posts: 3799
Joined: Thu Sep 11, 2008 5:31 am
Location: Myszków, Poland
Contact:

Re: EASY.SQL.2025.09.01 (A lot of new stuff!)

Post 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
Post Reply