ReadFromStream(Stream: IIOStream);
None;
Stream. Stream - source for reading data.
The ReadFromStream method reads the element of the binary data collection from the stream.
To write data to the stream, use the IAdhocBinaryItem.WriteToStream method.
Executing the example requires a form containing the Button component with the Button1 identifier. The repository must contain a dashboard with the AN_PAN name. Add links to the Metabase, Adhoc, Fore, Io system assemblies.
Sub UserProc;
Var
MB: IMetabase;
File1, File2: IFileInfo;
BR: IBinaryReader;
BW: IBinaryWriter;
AP: IAdhocReport;
BI: IAdhocBinaryItem;
BD: IAdhocBinaryData;
Begin
MB := MetabaseClass.Active;
AP := MB.ItemById("AN_PAN").Edit As IAdhocReport;
// Collection of binary data
BD := AP.BinaryData;
// Files for reading and writing
File1 := New FileInfo.Attach("c:\Image.jpg");
File2 := New FileInfo.Attach("c:\New_Image.jpg");
// Open file for reading
BR := File1.OpenBinaryReader;
// Open file for writing
BW := File2.OpenBinaryWriter(True);
// Clear binary data collection
BD.Clear;
// New element of binary data collection
BD.Add;
BI := BD.Item(0);
// Read from the stream
BI.ReadFromStream(BR.Stream);
// Element type
BI.Type := AdhocBinaryType.Png;
// Write to stream
BI.WriteToStream(BW.Stream);
(AP As IMetabaseObject).Save;
AP := Null;
End Sub UserProc;
After executing the example the document of binary type containing data from the Image.jpg file will be created and linked to the dashboard. The data from the created document will be written to the New_Image.jpg file.
See also: