This article covers a few examples of Sending files with FTP (or FTPS).
Note: SFTP is not FTP, please click here if you need SFTP ;-)
Good practice: using an FTP metadata
A Stambia Process can connect to an FTP server with the "Send files with FTP" action (also known as "FtpPut").
One can set the action's properties directly, or setup an FTP Metadata, which provides benefits such as Configurations, Impact analysis, Metadata management in Analytics, etc.
We recommend to setup an FTP Metadata (and this article respects this recommendation).
Sending a single file to an FTP server
In this example, we want to send a Local file (local to the Runtime) to the remote FTP Server.
Steps to create the process:
- Create the FTP Server metadata and a TargetDir folder
- Add a "Send files with FTP" action from the Palette
- Drag and drop the FTP Server's target directory from the FTP Metadata to the FtpPut action
- Set the FTP_LOCAL_FILENAME property to the local file path, e.g. "d:/temp/screen.png"
- Uncheck "Multiple Mode" because we want to transfer only one file
Note the (1) red circle: these properties are automatically set from the Metadata.
After execution: the FILE_NB variable confirms we have transferred 1 file.
Sending multiple files to an FTP Server
This time, we want to send all the files from a local directory, having a ".png" file extension.
Here is how we setup the FtpPut action:
- Make sure "Multiple Mode" is checked
- Local Path is the local directory containing the files
- Local Filename is the pattern for the file names : *.png
After execution: FILE_NB shows that we have sent 6 files.
FTP doesn't permit to indicate multiple file masks to retrieve at the same time.
But it is possible in Stambia, with the use of an XSL variable and repetition queries.
The XSL Variable
First, we need an XSL variable, which contains all the file's masks.
Example of code for the variable :
Next, we have to make the FTP action use a repetition query, to make it executes for each of the masks.
The repetition query is configurable in the
Generation tab of the properties of the action.
Finally, we have to configure the FTP_REMOTE_FILENAME parameter to use the filter on each repetition.
We do this by setting it to the xpath expression:
filter refers here to the Variable Name specified in the Repetition Query.