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.WriteFile
Writes a file with the given container.
| Component | Version | macOS | Windows | Linux | Server | FileMaker iOS SDK |
| Container | 6.4 | Yes | Yes | Yes | Yes | Yes |
Parameters
| Parameter | Description | Example |
|---|---|---|
| Data | The container field or value to save. | $Image |
| FilePath | The native file path. Something like "/Users/cs/desktop/test.jpg" on Mac and "C:\Programs\Data\test.jpg" on Windows. Files without path end in the root directory on Mac. | "test.jpg" |
Result
Returns OK or error.
Description
Writes a file with the given container.See also Files.WriteFile for more options.
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
Read a file and write it elsewhere
Set Variable [$Image; Value:MBS( "Container.ReadFile"; "/Users/cs/Pictures/Test.jpg")]
Set Variable [$r; Value:MBS( "Container.WriteFile"; $Image; "/Users/cs/Desktop/target.jpg")]
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 ) ]
Write a HTML file and an image file to load in web viewer:
Set Variable [ $folder ; Value: MBS( "Folders.UserTemporary" ) ]
Set Variable [ $path ; Value: MBS( "Path.AddPathComponent"; $folder; "test.jpg" ) ]
Set Variable [ $r ; Value: MBS( "Container.WriteFile"; Images::Image; $path ) ]
#
Set Variable [ $html ; Value: "<html><body><p>Hello World</p><img src=test.jpg width=300></body></html>" ]
Set Variable [ $path ; Value: MBS( "Path.AddPathComponent"; $folder; "test.html" ) ]
Set Variable [ $r ; Value: MBS( "Text.WriteTextFile"; $html; $path ) ]
#
Set Variable [ $URL ; Value: MBS( "Path.FilePathToFileURL"; $Path ) ]
Set Web Viewer [ Object Name: "web" ; URL: $URL ]
See also
- Container.ReadFile
- Container.WriteArchive
- Files.WriteFile
- ImageCapture.PDF
- MapView.Screenshot
- Path.AddPathComponent
- Path.LastPathComponent
- Screenshot
- ScreenshotRect
- Text.WriteTextFile
Example Databases
- CURL/Email/IMAP Email
- DynaPDF/Place Picture
- DynaPDF/Signature Appearance
- Mac and iOS/MapKit/MapView BeeExample
- Mac and iOS/MapKit/MapView
Blog Entries
- FileMaker 18 File Script Steps vs. BinaryFile functions
- Storing files for download on FileMaker Server with download URLs
- LogicalDOC Webservice
- Xojo Web Apps on FileMaker Cloud Server
- Comparing Base Elements Plugin to MBS FileMaker Plugin
- MBS FileMaker Plugin, version 6.4pr6
FileMaker Magazin
Created 6th September 2016, last changed 23th February 2020
Container.WriteArchive - ContinuityCamera.Clear
Feedback: Report problem or ask question.
Links
MBS Xojo Plugins