How to compress Blob Fields lazarus / 16-Databases ---------------------------------------------------------------------- DeBritto · 2016-05-27 18:33 Hi folks, I would like to know if it's possible to compress (using Zlib functions or something else) a string before stores the value in a Firebird Blob field? I'm asking because I'm developing an remote server-cliente application  that needs to share lots of information through internet and this strategy could save some time. Best regards ---------------------------------------------------------------------- Cyr · 2016-05-27 19:00 This is my code (not the best decision may be) to save some compressed data in to the BLOB field: uses ...., ZStream procedure TForm1.CargoGrid3DButtonClick(Sender: TObject; aCol, aRow: Integer); var  OutVertexStream,OutIndexStream: TMemoryStream;  GzStream1,GzStream2 : Tcompressionstream;  i:longint;  s: string;  d: Char; begin   if loadfromstl=false then exit;   OutVertexStream := TMemoryStream.Create;   OutIndexStream := TMemoryStream.Create;    try       GzStream1 := Tcompressionstream.create(clmax,OutVertexStream);       GzStream2 := Tcompressionstream.create(clmax,OutIndexStream);       try         GzStream1.WriteBuffer(vertex[0],length(vertex)*12);         GzStream2.WriteBuffer(vertexindex[0],length(vertexindex)*sizeo f(vertexindex));       finally          GzStream1.free;          GzStream2.free;       end;       OutVertexStream.Position:=0;       OutIndexStream.Position:=0;       SQLQuery1.Close;       SQLQuery1.SQL.Clear;       s:='select * from CargoTypeSizes where CargoTypeSizeID='+CargoGrid3D.Cells[0,CargoGrid3D.Row];       SQLQuery1.SQL.Text :=s ;       SQLQuery1.Open;       SQLQuery1.Edit;       s:='';       for i := 1 to OutVertexStream.Size do        begin          OutVertexStream.Read(d, 1);          s := s + d;        end;       SQLQuery1.FieldByName('vertexes').AsString:=s;       s:='';       for i := 1 to OutIndexStream.Size do        begin          OutIndexStream.Read(d, 1);          s := s + d;        end;       SQLQuery1.FieldByName('indexes').AsString:=s;       SQLQuery1.Post;       SQLQuery1.Upda]"]>Blockedde := upWhereAll;       SQLQuery1.ApplyUpdates;       SQLTransaction1.Commit;    finally       CargoGrid3D.Cells[2,CargoGrid3D.Row]:='loaded';       CargoGrid3D.Cells[3,CargoGrid3D.Row]:=inttostr(OutVertexStream.S ize+OutIndexStream.Size);       OutVertexStream.free;       OutIndexStream.Free;    end;   end; ---------------------------------------------------------------------- DeBritto · 2016-05-28 03:02 Hi Cyr, Thank you so much to share your code! I'll try it. But, let me ask you one more thing, you said that maybe this is not the best decision (to compress data into the Blob field). Why? Can you share some thoughts? Best regards