Subject Re: [IBO] Stream/FileSave to Blob
Author Geoff Worboys
> Does anyone have some simple examples they could share
> of saving a document or stream to a Blob?
>
> I have been trying to do this via BlobStream without success.


Reading a stream from a blob field...

var
Strm: TIB_BlobStream;
begin
Strm :=
IB_Query1.CreateBlobStream(IB_Query1.FieldByName('BLOBFIELD'),
bsmRead);
try
// do something with the stream
finally
Strm.Free;
end;


Write a stream to a blob field...

var
Strm: TIB_BlobStream;
begin
Strm :=
IB_Query1.CreateBlobStream(IB_Query1.FieldByName('BLOBFIELD'),
bsmWrite);
try
// do something with the stream
finally
Strm.Free;
end;


Or you can use the TIB_Column's Assign and AssignTo capability (not
just for streams but also for various types, see the online help).

Write blob field to AStream
IB_Query1.FieldByName('BLOBFIELD').AssignTo( AStream );

Load blob field from AStream
IB_Query1.FieldByName('BLOBFIELD').Assign( AStream );


Or perhaps the LoadFromStream, SaveToStream, LoadFromFile, SaveToFile
methods?


Mostly it depends on what you need.

Geoff Worboys
Telesis Computing