Topics   All   MacOS (Only)   Windows (Only)   Linux (Only, Not)   iOS (Only, Not)  
Components   Crossplatform Mac & Win   Server   Client   Old   Deprecated   Guides   Examples
New in version: 9.0   9.1   9.2   9.3   9.4   9.5   10.0   10.1   10.2   10.3    Statistic  


Writes selected data content from a container to a file path.

Component Version macOS Windows Server FileMaker Cloud FileMaker iOS SDK
Container 1.6 Yes Yes Yes Yes Yes
MBS( "Container.Export"; Container; Index or Type; FilePath )   More


Parameter Description Example value
Container The container where the data is stored.
Index or Type Specify a type (like "JPEG", "PDF ", "GIFf" or "PICT") or the index "JPEG"
FilePath Absolute path to store file.


Returns "OK" on success or error message.


Writes selected data content from a container to a file path.
For example you can write out from a TIFF image stored in the database the TIFF data itself or the preview JPEG.
Please note that types are always 4 characters long, "PDF " has a space on the end.
Some of the allowed types include "TIFF", "PDF ", "PNGf", "GIFf", "BMPf", "EPS ", "PICT", "M4V ", "WAV ", "M4A ", "MOV ", "AVI ", "AU ", "MP3 ", "MPEG", "MPG4", "AIFF", "8BPS", "FILE", "MAIN", "JPEG" and maybe some more.

To convert image formats, please review GraphicsMagick functions like GMImage.NewFromContainer and GMImage.WriteToPNGContainer.
To convert PDF to PNG, check functions like PDFKit.GetPDFPageImage, DynaPDF.GeneratePreview or DynaPDF.RenderPage.

This function is only for internal containers. Please use Container.WriteFile for all containers.

This function requires a native path. Use Path.FileMakerPathToNativePath to convert a FileMaker path to a native path if required. If you like to have the user choose the path, you can use FileDialog functions.
For Server be aware that server has limited permissions and may not be able to access all files on a computer.


Export JPEG file:

MBS("Container.Export"; Files::data; "JPEG"; GetAsText(Files::data)+".jpg")

Export all streams in container to individual files:

Set Variable [$container; Value:Test::Image]
#where to save
Set Variable [$DesktopFolder; Value:MBS("Folders.UserDesktop")]
#loop over streams in container
Set Variable [$count; Value:MBS( "Container.GetCount"; $container )]
Set Variable [$index; Value:0]
    #query the type of stream with given index
    Set Variable [$type; Value:MBS( "Container.GetType"; $container; $index )]
    #write it to a file
    Set Variable [$path; Value:$DesktopFolder & "/" & $type]
    Set Variable [$r; Value:MBS( "Container.Export"; $container; $index; $path )]
    Set Variable [$index; Value:$index + 1]
    Exit Loop If [$count = $index]
End Loop

Export a container to desktop:

# get path stored in the container field
Set Variable [ $ContainerPath ; Value: GetAsText ( Contacts::Photo Container ) ]
# get the file name portion
Set Variable [ $ContainerName ; Value: MBS( "Path.LastPathComponent"; $ContainerPath ) ]
# take a folder on the computer, e.g. desktop
Set Variable [ $DesktopFolder ; Value: MBS( "Folders.UserDesktop" ) ]
# build path with file name on that folder
Set Variable [ $FilePath ; Value: MBS( "Path.AddPathComponent"; $DesktopFolder; $ContainerName ) ]
# and export the content of container to that path
Set Variable [ $r ; Value: MBS( "Container.WriteFile"; Contacts::Photo Container; $FilePath ) ]

See also

Example Databases

Blog Entries

Created 18th August 2014, last changed 22nd November 2019

Container.Deserialize   -   Container.ExtractStream

Feedback: Report problem or ask question.

MBS Xojo Plugins