File Triggers and Actions - File Copy Action

Copies a group of source files to a group of targets. At workflow execution time, if at least one error occurs, a FileActionException is thrown.

Results

The File Copy Action returns its results in the flow context variable “result”. These results include listings of all files that were successfully copied, including source locations and target destinations, in various formats. You can access the file copy results from the following fields:

Flow Context Variable Field Java Type Description Prescript / Postscript Example
RESULT filenames Map<String, String> A map of file sources to destinations for files that were successfully copied.
The keys of the map are the original filenames for the source file that was copied. The values of the map are the filenames of the files as stored at the destination location.
This result contains file names only and does not include file path/directory information.
For example, if the action copies a file from /outputs/atlanta/settlements.zip to an FTP location /inputs/atlanta/settlements_final.zip, this result will contain an entry for that copy with the key settlements.zip and the value settlements_final.zip.
Map filenames = flowContext.get("RESULT").filenames; for (String filename : filenames.keySet()) { System.out.println("Source: " + filename); System.out.println("Target: " + filenames.get(filename)); }
RESULT url_objects Map<URL, URL> A map of file sources to destinations for files that were successfully copied.
The keys of the map are URL objects containing the location of the source file that was copied. The values of the map are URL objects with the location of the files at the destination location.
This field contains the same information as the “url_strings” field, except file names, are stored as URL objects, not strings.
For all non-file protocols, this map contains the same information as the “url_strings” field.
Map fileurls = flowContext.get("RESULT").url_objects; for (String fileurl : fileurls.keySet()) { System.out.println("Source: " + fileurl); System.out.println("Target: " +fileurls.get(fileurl)); }
RESULT url_strings Map<String, String> URLs of files for which the file action was carried out successfully.
This field contains the same information as the “url_objects” field, except file names, are stored as strings, not URL objects.
Map fileurls = flowContext.get("RESULT").url_strings; for (String fileurl : fileurls.keySet()) { System.out.println("Source: " + fileurl); System.out.println("Target: " + fileurls.get(fileurl)); }

Passing Results with a Runtime Data Map

You can use a Runtime Data Map to specify one of the result fields as a collection on a For Each Collection Element Action, or to copy the result field into a new variable.

To set the collection for a For Each Collection Element Action, add the following data map on the flow going into the For Each action:

Screen_Shot_2022-03-02_at_1.42.28_PM.png Insruction 1 of 2

To copy the collection into a new variable (for future reference or to reuse the data later in the workflow), you could use a data map like:

Insruction 2 of 2