I think (hope) that I have a rather simple question for ZEOS experts: We defined a table for uploading files to a Postgres 8.3 database, currently still with Zeos 6.6.6 stable, protocol "postgresql-8".
Definition of the table looks like this:
Code: Select all
CREATE TABLE files
(
"ID" serial NOT NULL,
"Customer" integer,
"Filename" character varying(60),
"Data" bytea,
CONSTRAINT files_pkey PRIMARY KEY ("ID" )
)
For uploading files, I tried two possibilities:
1. Create ZQuery with am INSERT SQL and named parameters. Load the blob parameter with:
Code: Select all
qryInsert.ParamByName('data').LoadFromFile(filename, ftBlob);
qryInsert.ExecSQL;
2. Create a IZPreparedStatement with an INSERT SQL command, position-based parameters (?). Load the blob parameter into a stream and then:
Code: Select all
PreparedStatement.SetBinaryStream(3, FileStream);
Both approaches work fine - however they encode the binary data into a string like this:
Code: Select all
'\\\\377\\\\330\\\\377\\\\340\\\\000\\\\020JFIF....
This would not be critical if our 10MB images wouldn't be increased about four times when encoded. I searched the forums and found that others manage to send unencoded data - but how?