Welcome Guest! Log in


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:
  1. 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).
  2. Boolean type properties return true if the condition is fulfilled.
  3. 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.

  1. Open your File Metadata
  2. Right click on the File and choose New > Property Field
  3. Fill the name with the property you want to use.
  4. Repeat the process for each needed property.

 

createPropertyFields

 

Moreover, you have the possibility to prefix all the Property Fields, if needed.

  1. Open your File Metadata
  2. Navigate to the file standard properties
  3. Set the Property Field Prefix property.
  4. Prefix your Property fields.

 

prefix

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:

sourceMapping

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.

targetMapping

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.

ProcessFileAsSource

 

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.

ProcessFileAsTarget

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.

 

Comments  

# Virginie_Samson 2019-05-07 15:52
:lol:

You have no rights to post comments

Articles

Suggest a new Article!