Bearbeiten

Freigeben über


Media.ExportStream(OutStream) Method

Version: Available or changed with runtime version 1.0.

Exports 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.

Syntax

[Result := ]  Media.ExportStream(Stream: OutStream)

Parameters

Media
 Type: Media
An instance of the Media data type.

Stream
 Type: OutStream
The OutStream object that is created by the object that will receive the media content.

Return Value

[Optional] Result
 Type: Boolean
true if the media was successfully exported, otherwise false. If you omit this optional return value and the operation does not execute successfully, a runtime error will occur.

Example

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 Method (Media) or ImportStream Method (Media).

 var
    myItemRec: Record "My Items";
    fileName: Text;
    count: Integer;
    exportFile: File;
    dataOutStream: OutStream;
    Text000: Label '%1 media files were exported';
begin
    if myItemRec.FindFirst() then begin  
        repeat begin
            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;
        end until myItemRec.Next < 1;
        Message(Text000, count);
    end;  
end;
    

Media Data Type
Get Started with AL
Developing Extensions