恢复在 sql 数据库中存储为 blob 的文档

restore documents which are stored as blobs in a sql database

我从客户那里得到了一个 sql 数据库。在 sql 数据库中有一个 table,称为 "documents"。文档存储为 blob(查看屏幕截图)。

我想通过 Delphi(FileStream?)恢复文件。你知道怎么做吗?

此致, 丹尼斯·弗里德里希

function SaveFieldBlobToFile(FQuery: TDataSet): boolean;
var MyStream : TMemoryStream;
begin
   Result:= false;
   MyStream:= TMemoryStream.Create;
   try
     (FQuery.Fieldbyname('MODELE') as TBlobField).SaveToStream(MyStream);
    if (MyStream<>nil) and (MyStream.Size > 0) then
    begin
      MyStream.Position := 0;
      MyStream.SaveToFile('C:\Temp\tempMyFile.zip');
      Result:= true;
    end
    else Result:= false;
  finally
    MyStream.Free;
  end;
end;


function LoadFileToBlob(FQuery: TDataSet): boolean;
var MyStream : TMemoryStream;
begin
  Result:= false;
  MyStream := TMemoryStream.Create;
  try
    MyStream.LoadFromFile('C:\Temp\tempMyFile.zip');
    MyStream.Position := 0;
    TryEdit(FQuery);
    (FQuery.FieldByName('MODELE') As TBlobField).LoadFromStream(MyStream);
    TryPost(FQuery);
    Result := True;
  finally
    MyStream.Free;
  end;
end;