To File

The To File component is a destination component that writes incoming data to a file or multiple files as needed. It serves to expand on the File Writer component with additional configurations and settings.

This adapter can be easily modified to add additional functionality or to fulfil extra requirements.

Running the Component

The below steps assume the correct user permissions are in place to read/write files.

Using +COMPONENT, import the To File component.

Screen Shot 2024-08-02 at 2.56.33 PM.png

Fields marked with an asterisk* are required, otherwise default values defined in config.json are used:

Field

Description

Default Value

Field

Description

Default Value

DestinationDirectory *

The directory where the output file(s) will be stored. The adapter will attempt to create it if it does not exist.

-

OutputFileMask

The name and extension of the output files.

%Y (year), %m (month), %d (day), %H (hour), %M (minute), %S (second) and %f (millisecond)

output_%Y_%m_%d_%H_%M_%S.txt

OneFilePerMessage

Specifies whether each inbound message will have its own file.

false

OutputEncoding

The encoding used in the output file.

If left blank, encoding will be updated to the default according to OS. See Supported File Encodings.

Western (Windows-1252) for Windows

Western (ISO-8859-1) for Linux/Mac OS X.

Escape8BitCharacters

Specifies whether to escape non-ASCII characters in outbound messages.

Ex. "é" would be sent as "\XE9\" (in Latin-1 or Windows-1252) or "\XC3\\XA9\" (in UTF-8).

false

UseTempFiles

Specifies whether to use temporary files while writing.

When true, it will append “.tmp” to files currently being written until the component is done writing to them. It will only remove the .tmp extension when a new file is written in.

true

Start the component.

Once inbound messages are processed, check the defined destination directory to see your newly created file(s).

Example Configurations

If you want one file for all messages:

  • Set OneFilePerMessage to false

  • This will result in a single “output.txt“ file containing all messages.

Screen Shot 2024-08-12 at 2.28.27 PM.png

The OutputFileMask will behave differently depending if OneFilePerMessage is set to true:

  • OneFilePerMessage set to false will result in a single file “output.txt“ that all the incoming data will be written to.

  • OneFilePerMessage set to true will result in individual files generated as output.txt, output(1).txt, output(2).txt and so on. Similarly, with a timestamp mask “output_%Y_%m_%d_%H_%M_%S.txt”, if two messages come in at the same time then the name of the files will be: “output_2024_12_30_16_45_55.txt” and “output_2024_12_30_16_45_55(1).txt”

If you want one file for every message:

  • Set OnFilePerMessage to true

  • Using the default OutputFileMask, the timestamp will be updated with the current time, each time a message is written to the file.