EXPORTSTREAM Function (Media)
Export the current media object (such as a JPEG image) that is used on record to an OUTSTREAM object.
The OUTSTREAM object can be created from a BLOB field, a FILE or from a .NET Framework interoperability object. In the record, the media is referenced in a Media data type field.
[Ok := ]Record.MediaField.EXPORTSTREAM(OutStream)
Specifies the record that includes the media.
Specifies the Media data type field of the record that includes the media.
Specifies the OutStream object that is created by the object that will receive the media content.
Property Value/Return Value
true if the media was successfully exported; otherwise, false.
The OutStream object must be a valid and writeable stream that is created by the receiving object. The EXPORTSTREAM function does not create the OutStream object. It only uses the object for writing data.
This example uses the EXPORTSTREAM to iterate over a sample table named My Items table and export any media that is used on records to an OutStream that is created on a file object.
This example assumes that the My Item table contains a Media data type field that is named Image, and that you have already imported some media on records. For information about importing media, see IMPORTFILE Function (Media) or IMPORTSTREAM Function (Media).
The example code requires that you create the following variables and text constant:
|Text constant name||ConstValue|
|Text000||%1 media files were exported.|
IF myItemRec.FINDFIRST() THEN BEGIN REPEAT IF myItemRec.Image.HASVALUE THEN BEGIN fileName := 'C:\images\export\' + 'ItemPictureFromStream' + FORMAT(myItemRec."No.") + '.jpg'; exportFile.CREATE(fileName); exportFile.CREATEOUTSTREAM(dataOutStream); myItemRec.Image.EXPORTSTREAM(dataOutStream); count := count + 1; exportFile.CLOSE; END UNTIL myItemRec.NEXT < 1; MESSAGE(Text000, count); END;
Send feedback about: