This rule will detect a file upload to the c:\ftproot\test\uploads folder by a user named user, and will execute the 'Transfer File' target to send the file to another server.
Add the Event Target
To use the new functionality, start by creating a new Event Target. This document contains the instructions on how to create the Event Target: Event Manager: Add a File Transfer Event Target for FTP, FTPS ,SFTP or HTTP/S PUT/GET
Create the 'Send A File' Rule
Add the New Rule
Once you can connect to your server, click Update and move on to the 'Event Rules' tab. This example describes a rule that transfers a file in response to an incoming 'File Transfer Event.'
- Go to the Event Rules page of the Event Manager
- Click the New button. The Add A New Event Rule dialog will appear.
- Select the File Transfer Event Rule Type for your new rule. This event type will cause the rule to be triggered whenever a file transfer takes place.
- Enter a name for your rule in the Rule Name edit box. For example, 'Forward Uploaded File'.
- Press the Add a New Rule button on the Add A New Rule dialog to save and add the new Event Rule. The event rule will be selected and ready for editing on the Edit Rules page.
Add the Rule Conditions
Select the Match If All Filters Match mode. Selecting this option means that this rule will only be triggered whenever the rule’s event occurs and if all of the conditions listed are fulfilled.
To prevent the system from sending every incoming file, click New button to add a condition and set the Variable to '{{LPNT}} Local File Parent Directory', Comparison to 'Contains' and Value to a directory path like 'ftproot\test\uploads' that you create in your path. Click the Add button.
Click New button to add a condition and set the Variable to '{{D}} Download', Comparison to 'Equals' and Value to 'False', meaning trigger on an upload. Click the Add button.
Click New button to add a condition and set the Variable to '{{S}} Success', Comparison to 'Equals' and Value to 'True', meaning only trigger on a successful upload. Click the Add button.
Add the Rule Actions
Add a new action and select Send a File in the 'Action' drop down. In the Using drop-down, select the Event Target created in the Event Targets step. See the ‘Send a File Event Action’ screenshot below.
Since the action is sending a file that just came in, we can set File Path From to {{LFP}} which is a variable representing the 'Local File Path.' And for File Path To, we can select {{LFN}} which is just the filename part of the incoming file.
Clicking Add will complete the Rule and show a summary like:
Send file to 'ftp://user@example.com/newfolder/{{LFN}}' from '{{LFP}}'
Send a File Event Action
Test the transfer by uploading a file to the directory 'test\uploads' and verify that it is transferred to the remote server and placed in the 'newfolder' directory with the same filename as your original file.
If you have any issues, make sure DEBUG is enabled in the Log as discussed above, trigger the transfer, and look at the debugging and error messages.
Comments
0 comments
Article is closed for comments.