Topics
All
MacOS
(Only)
Windows
(Only)
Linux
(Only, Not)
iOS
(Only, Not)
Components
Crossplatform Mac & Win
Server
Client
Old
Deprecated
Guides
Examples
Videos
New in version:
9.3
9.4
9.5
10.0
10.1
10.2
10.3
10.4
10.5
10.6
Statistic
FMM
Blog
Container.Export
Writes selected data content from a container to a file path.
| Component | Version | macOS | Windows | Linux | Server | FileMaker iOS SDK |
| Container | 1.6 | Yes | Yes | Yes | Yes | Yes |
Parameters
| Parameter | Description | Example |
|---|---|---|
| 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
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
- Container.GetCount
- Container.GetType
- Container.WriteFile
- DynaPDF.GeneratePreview
- DynaPDF.RenderPage
- Folders.UserDesktop
- GMImage.New
- GMImage.NewFromContainer
- Path.AddPathComponent
- Path.FileMakerPathToNativePath
Example Databases
Blog Entries
- MBS FileMaker Plugin, version 5.1pr7
- Filemaker: Export Text to File
- MonkeyBread Software Releases the MBS Filemaker plug-in 1.6
Created 18th August 2014, last changed 22nd November 2019
Container.Deserialize - Container.ExtractStream
Feedback: Report problem or ask question.
Links
MBS FileMaker blog