Welcome Guest! Log in
Stambia versions 2.x, 3.x, S17, S18, S19 and S20 are reaching End of Support January, 15th, 2024. Please consider upgrading to the supported Semarchy xDI versions. See Global Policy Support and the Semarchy Documentation.

The Stambia User Community is moving to Semarchy! All the applicable resources have already been moved or are currently being moved to their new location. Read more…

Checking FTP Get result in Execution Condition

    When connecting to an FTP server, it can be useful to execute distinct branches of a process, depending on how many files were fetched.

    This can be done very simply, using an Execution Condition after the Get FTP action:

     

     598 getftp result

     

    Explanation:

    • Once the FtpGet Action is executed, its variable "FILE_NB" contains the number of files retrieved.
    • The links to the next actions have an Execution Condition, based on this variable: ${FtpGet/FILE_NB}$
    • Make sure that your Execution Condition refers to the appropriate variable path, matching your FtpGet action's name, for example ${MyFtpAction/FILE_NB}$

    Stambia DI for FTP

      Stambia Data Integration allows to work with FTP servers.

      FTP Metadata is available to define all the server's credentials and communication properties, and to specify the distant FTP folders.

      It can then be used with the dedicated FTP Process Actions to send or receive files and to perform FTP commands on the remote server.

      Read more: Stambia DI for FTP

      Sending files with FTP or FTPS

        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

        576 singlefile

         

        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

         

        576 multiplefiles

         

        After execution: FILE_NB shows that we have sent 6 files.

         

        How to retrieve multiple file with different mask in FTP

          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.

          processWithFilter

          Example of code for the variable :

          %xsl{
          <value name="*.txt"/>
          <value name="*.proc"/>
          }%

           

          Repetition query

          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.

          filter

          FTP_REMOTE_FILENAME parameter

          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: %x{$filter/@name}x%

          Note: filter refers here to the Variable Name specified in the Repetition Query.

          remoteParameter

           

           

           

          Articles

          Suggest a new Article!