Altova MapForce 2023 Enterprise Edition

Example: Read Binary Files

Home Prev Top Next

The mapping illustrated below reads data from an image file and writes it to a database table. The target database is SQLite. Notice that the data type of the picture database field is BLOB.


To extract binary content from the file, the read-binary-file function was used. In this example, the first argument, filepath, is supplied by a constant. Note that, because the path is relative, MapForce will look for the image file in the same directory as the mapping.


The mapping populates the following fields in the target database:


id - In this example, the database component is configured so that id is database-generated rather than being supplied by the mapping. For more information, see Inserting Data into a Table.


title -  This value is provided by a simple input component with the same name. Note that a design-time execution value is set ("product1") in order to make it possible to preview the mapping. For more information, see Supplying Parameters to the Mapping.


picture - This field receives the direct output of the read-binary-file function.


Because the target component is a database, previewing the mapping generates a pseudo-SQL script that you can review, but does not send any changes to the database. To run the actual script against the database, select the menu command Output | Run SQL-Script.

© 2016-2022 Altova GmbH