Page 1 of 1

Saving binary data to a blobfiled

Posted: 24.08.2014, 08:27
by pal1952
Zeoslib 7.1.3 Stable, Delphi XE4, Windows 7

I am trying to save binary data (exe files) into a blob field (longblob) using the following code:

When I execute it I get "MySql server has gone away". It does work on smaller files < 1MB.

Any ideas.


try
Import := TZTable.Create(nil);
Import.Connection := Connection;
Import.TableName := 'Versions';
Import.Open;

Import.Insert;
Import.FieldByName('FileName').AsString := ExtractFileName(FileName);
Import.FieldByName('VersionNo').AsInteger := ExistingVersion.AsInteger;
Import.FieldByName('CRC').AsInteger := CRC;

try
FileStream := TFileStream.Create(FileName, fmOpenRead);
TBlobField(Import.FieldByName('Exe')).LoadFromStream(FileStream);

finally
FileStream.Free;
end;

Import.Post;

Import.Close;
finally
Import.Free;
end;

Re: Saving binary data to a blobfiled

Posted: 24.08.2014, 13:45
by EgonHugeist
Hi,

AFAIR is this related to server-settings. Execute 'SET GLOBAL max_allowed_packet=16*1024*1024;'
And another suggestion:

Add 'preferprepared=True' to the TZDataSet.Properties. This parameter enables the MySQL real-prepared stmt and this can send lob's in chunks.

Re: Saving binary data to a blobfiled

Posted: 25.08.2014, 06:47
by pal1952
Hi

Thanks you for the "set global" comment, it fixes the problem perfectly; I have changed the server ini now. I had wondered if it was a setting, I should have thought before I posted.

I will try the "prefer prepared" line.

Thanks for the help.

Peter