In this tutorial, we're going to show you how to automatically upload files to a remote server as soon as the files are added into one of your MFT Server's local directories.
What we're trying to achieve
Let me explain what we're trying to do here. Basically, we want to automate a process wherein files are uploaded to a remote server as soon as they arrive at a designated folder/directory. These files might be coming from different business processes or systems in your local IT environment and need to be forwarded to a trading partner or business unit in another geographical location.
Let's now go through the steps needed to achieve this.
1. Create a Directory Monitor for detecting files that are added to a designated directory
First, we need a way to automatically detect that files have arrived at the directory in question. To do that, we create what is known as a Directory Monitor. This directory monitor should be configured to monitor the directory in question for files added.
To create a Directory Monitor, go to the Directory Monitors module and click the Add button.
You should then be prompted to enter the Directory Monitor parameters. Give the Directory Monitor a Name (e.g. "Monitor File Added ForCompanyABC") and select the specific Directory you want to monitor.
Make sure the "Monitor file add" checkbox is ticked.
As soon as you're done, click the OK button to proceed.
Once you're back at the main screen, you should then see your newly created Directory Monitor in the Directory Monitors tab.
The Directory Monitor you just created will fire a "Directory Monitor File Added" event type as soon as a file is added to the directory. Note that each file added to the directory will fire one instance of the said event. So if five (5) files are added, then 5 such events will be subsequently fired. The next thing we need to do is create a trigger that would respond to these events.
2. Add a trigger that responds to the "Directory Monitor File Added" event type
Go to the Triggers module and click the Add button.
When you're asked to specify the trigger parameters, give the trigger a descriptive name (e.g. "Upload To CompanyABC") and select the "Directory Monitor File Added" Event type. Click Next to proceed.
Because you might also be monitoring several other directories, you'll want to configure this trigger so that it only responds to a specific Directory Monitor. In our case, that would be the monitor named "Monitor File Added ForCompanyABC".
To do that, just enter the expression: MonitorName = "name_of_directory_monitor"
If you want to see what other conditions you can put together, I suggest you click those buttons below the Expression box.
Click Next to proceed.
3. Add a trigger action for uploading the newly added files to the remote server
Let's now move on to the last part of this process. This is the part that uploads the files to the remote server.
Click the Add button to add a trigger action.
If you scroll down the list of trigger actions, you'll notice that you have several "file upload" trigger actions at your disposal. You can upload to different file transfer servers, including FTP, FTPS, SCP, WebDAV, etc. For this example, we'll just choose the "SFTP File Upload" trigger action, which will upload our files to a remote SFTP server.
Click OK to proceed.
Enter pertinent details of the remote SFTP server. The most commonly used parameters include the Hostname/IP address, Port number (normally 22 for SFTP), Username, and Password.
You also need to specify the Local File you want to upload. Because we want to upload each file that's added into the monitored directory, the best way to go about this would be to use the %File% variable. The value of the %File% variable in this particular context is the local path of the file that was recently added to the directory.
If multiple files are added to the directory, then the value of the %File% variable will change. Each instance of the Directory Monitor File Added event will correspondingly have its own value for the %File% variable.
Lastly, you can specify the remote directory where the files will be uploaded to. In our case, we just used the forward slash (/) to specify that we want the files to be uploaded to the remote user account's root directory.
That's it. After you click the subsequent OK buttons and get back to the main screen, you will have been done setting up JSCAPE MFT Server to automatically upload files to a remote server.
Would you like to try this out yourself? Download a free, fully-functional evaluation edition of JSCAPE MFT Server now.