# 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
```al
[Result := ]  Media.ExportStream(Stream: OutStream)
```
## Parameters
Media
Type: media-data-type
An instance of the media-data-type data type.
Stream
Type: ../outstream/outstream-data-type
The OutStream object that is created by the object that will receive the media content.
## Return Value
*[Optional] Result*
Type: ../boolean/boolean-data-type
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 media-importfile-method or media-importstream-instream-text-text-method.
```al
 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;

```
## Related information
media-data-type
Get Started with AL<../../devenv-get-started>
Developing Extensions<../../devenv-dev-overview>

Copyright (c) Microsoft Corporation. CC BY 4.0, https://creativecommons.org/licenses/by/4.0/; code samples MIT. From https://learn.microsoft.com/en-us/dynamics365/business-central/dev-itpro/developer/methods-auto/media/media-exportstream-method, MicrosoftDocs/dynamics365smb-devitpro-pb at 828b6ee (2026-11-19). Changed: includes filled in, links to this site, and for agents shortened without dropping a fact. https://jonas-paprotka.de/docs/dev-itpro/developer/methods-auto/media/media-exportstream-method/
