The To filesystem workflow component is found as one of the basic output workflow components.
With this you can tell the workflow to output any kind of payload (contents of the workflow) into an output directory (file system).
If you e.g. previously created a PDF file, and then added a digital signature to it, then you can use this component to place the signed PDF file in the file system.
The component accepts any payload as input.
This component is unavailable, if file system access has been disabled in the system settings.
This component writes the current workflow body to a file on the local file system.
The parameters are these:
Output directory
The output directory where the file is to be stored. "{{env:INTERFORMNG2_HOME}}" can be used as part of the path, to denote the INTERFORMNG2_HOME directory.
Output filename
What file name to use for the stored file.
File name conflict resolution
With this you specify what the workflow should do, if the file already exists. The options are:
Overwrite (default). If you select this, then any existing file with the same name will be overwritten by the new file.
Append version. Select this to add a counter (in parenthesis) at the end of the new file name - prior to the extension. Please read the warning below before using this option.
Rename existing. Rename the existing (old) file and add the timestamp to the file name. The old file will be rename similar to this: filename_20200812134611716.pdf.
Move existing. If you select this, then the original file will be moved to a subdirectory with the timestamp and the new file is created as requested.
With the file name conflict resolution you cannot be sure, what the output file was actually called, but you can get that information in the workflow after running this component, as the component updates the predefined variable, $interform.plugin.archiver.fileName with the actual correct name. This can e.g. be used, if you want to ensure, that an index file (created by the index data component) is named the same (except the extension) as the output PDF file, which is to be archived.
Not only can you select one of the fixed values above for the file name conflict resolution, but you can also use an XPath expression to set a variable value e.g. depending on the input file. The XPath expression should return one of these values:
Overwrite
Rename
AppendVersion
AppendTimestamp
Unknown values will result in "Overwrite" being used.
The following values are also accepted (InterFormNG related values), BUT will result in a warning
append-version-number
rename-existing-file
overwrite-existing-file
Here is an important note/warning when it comes to use of the option: Append version for the file name conflict resolution. You should consider this option as the last resort to ensure a unique file name i.e. it is e.g. very bad practice to simply store MANY files with a fixed name in a folder and then expect InterFormNG2 to rename the output files automatically with the append version option.
If you choose to e.g. save 100.000 files in this manner, then each new file that is created will run through the existing 100.000 files with the same name (and a number at the end) until finally a free number has been found, which will take up a lot of unnecessary time. So it is best practice to try the best to ensure that the append version option is only triggered in a very unlikely situation. InterFormNG2 contains multiple functions, that can help you to build a dynamic, unique file name. You can consider to concat a fixed part of the file name with e.g. the timestamp, contents from the file or the UUID and either only use these or even combine them with a fixed part like the examples below: