February 22, 2012
How to download files from database using Free Pascal/Lazarus
After uploading files in the previous example into database, now we need to download that files:
Create new Lazarus project to open and browse Photos table in this form:
Download button will prompt you to specify where to download the file.
Write this code in Download button’s OnClick:
procedure TForm1.Button3Click(Sender: TObject);
var
BlobStream : TStream;
M: TFileStream;
begin
SaveDialog1.FileName:= SQLQuery2.FieldByName('FileName').AsString;
if SaveDialog1.Execute then
begin
BlobStream := SQLQuery2.CreateBlobStream(SQLQuery2.FieldByName('Content'),bmread);
M:= TFileStream.Create(SaveDialog1.FileName, fmCreate);
BlobStream.Position:= 0;
M.CopyFrom(BlobStream, BlobStream.Size);
M.Free;
BlobStream.Free;
end;
end;

How to upload files into database using Free Pascal/Lazarus « Free Pascal Answers said,
February 22, 2012 at 8:15 am
[...] you can download it using this example Share this:TwitterFacebookLike this:LikeBe the first to like this [...]
alcatel said,
March 15, 2012 at 12:59 pm
Is it possible to display a progres indicator which could be important especially for big files?
أبو إياس said,
March 16, 2012 at 5:06 pm
May be it can be done by using threads. If I had a time I could try it and let you know.