« ProgressDialog functi… | Home | Teach your solution t… »

Container

Do you know the additional functions for containers that the MBS FileMaker Plugin offers? In this blog article I would like to introduce you to a few of them.

Let's start with the loading of a file into the container field. For this we use the function Container.ReadFile. With it we read files via a native file path. This path can be defined by a text field or by the FileDialog functions with the help of a dialog. This function can be used not only in FileMaker Pro, but also on the server. We must pay attention that the server is authorized to access the files, otherwise it does not work. Beside the file path also a mode can be specified. If no mode is specified, then the plugin itself tries to determine the file type and imports the file appropriately. If we specify the keyword container, the result is returned as a container with a FILE stream inside. If we specify compressed then we get a compressed container value returned. Finally, we can also specify the filename that the file should have.

Set Variable [ $image ; Value:MBS( "Container.ReadFile"; "/Users/cs/Pictures/test.jpg"; "auto")]

If you want to convert an image file directly into another format when importing into the container, e.g. you have a PNG that should be in JPEG format, then you can import the image file with Container.ReadImageFile and then specify the desired format in the parameters. Possible formats are JPEG, PNG, GIF or BMP. This function also makes it possible to convert a HEIC image into one of the four formats. You can see this also on the screenshot.

Set Field [ FMCert::Container ; MBS( "Container.ReadImageFile"; "/Users/sj/Desktop/IMG_5101.HEIC"; Test::Desired format) ]

But not only the import of files is possible, but also the export and for this we have the function "Container.Export". With this function it is possible to export only certain data streams of the container. For example you can write out from a TIFF image stored in the database the TIFF data itself or the preview JPEG. In the parameters you first specify the container you want to export, then as already mentioned the stream and finally the file path where the file should be stored.

Set Variable [ $image ; Value: MBS("Container.Export"; Files::data; "JPEG"; "/Users/cs/Desktop/target.jpg")]

If you simply want to write a container value as a file to a disk without reading a special stream, then you can also use the function Container.WriteFile, which we pass only the container and the file path, this can look like this

Set Variable [ $r ; Value: MBS( "Container.WriteFile"; Images::Image; "/Users/cs/Desktop/target.jpg") ]

These and many other functions are waiting for you in the component Container. Please try them and let us know your questions.

20 10 22 - 08:22