In this article
An interesting feature of the Stambia file driver is the possibility in Mappings or Processes to use the properties of a file, such as the file size, path, name or binary content, ...
This article summarizes all the available properties that can be used, and how with Mapping and Process examples.
Prerequisites:
- Stambia DI Runtime S17.3.0 or higher
- Stambia DI Designer S18.2.0 or higher
Available Property fields
Property name | Read |
Write | Type | Description |
file_number | X | number | Place of the file in the queue of found files. Useful in case of using file masks. | |
file_name | X | string | Name of the file. | |
file_absolute_path | X | string | Absolute path of the file. | |
file_canonical_path | X | string | Canonical path of the file. | |
file_path | X | X | string | Path of the file. When writing, a relative path can be provided. |
file_total_space | X | number | Total disk space. | |
file_usable_space | X | number | Usable disk space. | |
file_free_space | X | number | Free disk space. | |
file_can_execute | X | boolean | Indicates if the file can be executed. | |
file_can_read | X | boolean | Indicates if the file can be read. | |
file_can_write | X | boolean | Indicates if the file can be modified/written. | |
file_is_absolute | X | boolean | Indicates if the file path is absolute. | |
file_is_file | X | boolean | Indicates if it is a file. | |
file_is_directory | X | boolean | Indicates if it is a directory. | |
file_exists | X | boolean | Indicates if the file exists on the file system. | |
file_is_hidden | X | boolean | Indicates if the file is hidden. | |
file_length | X | number | File size in bytes. | |
file_last_modified | X | date | Last modified date. | |
file_parent_path | X | string | Path of the folder containing the file. | |
file_parent_absolute_path | X | string |
Absolute path of the folder containing the file. |
|
file_parent_canonical_path | X | string | Canonical path of the folder containing the file. | |
file_parent_name | X | string | Name of the folder containing the file. | |
file_parent_can_write | X | string | Indicates if there is write permission on the parent folder. | |
binary_content | X | X | binary | Whole content of the file retrieved directly as binary. |
string_content | X | X | string | Whole content of the file retrieved as string. |
Notes:
- Read column is used to indicates that the property can be used at reading (when doing selects on the file). Write column indicates that it can be used at write (when doing inserts).
- Boolean type properties return true if the condition is fulfilled.
- All the file permissions retrieved concern the user running the Runtime/Designer.
Important:
In Mapping and Processes, content Property Fields (binary_content and string_content) can't be used together with normal file fields. They are used to retrieved the whole content of the file, and there is then no sense to use them with normal file fields.
Using Property fields in a Mapping
Defining the fields in the file Metadata
To use the fields in a mapping, you'll first have to declare them on the File Metadata.
- Open your File Metadata
- Right click on the File and choose
New > Property Field
- Fill the name with the property you want to use.
- Repeat the process for each needed property.
Moreover, you have the possibility to prefix all the Property Fields, if needed.
- Open your File Metadata
- Navigate to the file standard properties
- Set the
Property Field Prefix
property. - Prefix your Property fields.
This can be particularly useful if you are in a situation where some normal fields have the same name as Property Fields.
Using the fields as source
You can now use these fields when using a file as source in a Mapping:
Using the fields as target
Three Property Fields can be used as target: string_content, binary_content and file_path.
They cannot be used together with normal file fields and are used to write the entire file through the content fields.
They are particularly useful to write PDF, DOCX, PNG, ... files directly from binary contents.
Note that you can provide relative paths in the file_path property. The directory containing the file will be automatically retrieved from the Metadata and added to the path.
Using Property fields in a Process
Property fields can be used in processes through the SQL Operation actions as usual like other fields.
Reading files
You can use the Property Fields when doing select queries on a file with SQL Operations and bind the result as usual.
Writing files
Like for Mappings, three Property Fields can be used as target: string_content, binary_content and file_path.
They cannot be used together with normal file fields and are used to write the entire file through the content fields.
They are particulary useful to write PDF, DOCX, PNG, ... files directly from binary contents.
In this process we retrieve the binary content stored in the HSQL table, and use it to create a file.
Note that you can provide relative paths in the file_path property. The directory containing the file will be automatically retrieved from the Metadata and added to the path.