Topics   All   Mac OS X (Only)   Windows (Only)   Linux (Only, Not)   iOS (Only, Not)  
Components   Crossplatform Mac & Win   Server (Not)   Client   Old   Guides   Examples
New in version: 6.1   6.2   6.3   6.4   6.5   7.0   7.1   7.2   7.3   7.4    Statistic  

Container.Export

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 )

Parameters

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.

Result

Returns "OK" on success or error message.

Description

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.

Examples

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]
Loop
    #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 )]
    #next
    Set Variable [$index; Value:$index + 1]
    Exit Loop If [$count = $index]
End Loop

See also

Example Databases


Container.Deserialize   -   Container.ExtractStream

Feedback: Report problem or ask question.




Links
MBS Xojo tutorial videos