Author : Chirag Mehta & Angelica Buffa
Using FTP servers to store and share files is very common now at days. Most language programs let you develop FTP clients and consume their services.
With Apex, there are three possible approaches to resolve the integration with this kind of file servers:
I – Data Loader CLI – Windows approach.
- Download Salesforce Data Loader Command Line Interface (Read more at http://wiki.developerforce.com/index.php/Using_Data_Loader_from_the_command_line)
- Write a Widows Batch file (.bat file)
- First command in the batch file will be connect to FTP server (ms-dos command ‘ftp’) and then get the necessary files from ftp server to the local folder.
- Second set of commands execute the Data Loader CLI jar and loads step3 retrieved file into Salesforce.
- To automate the execution of the batch, we can schedule the bat file execution using scheduled task feature of Windows operating system.
II – Java Web Service
- Write a Java FTP client, expose it as a Web Service
- Consume above WS into your Salesforce Org using Apex “Browse WSDL” functionality
III – Http Request
- Create a Http Request to the FTP server
- Handle the response using either of HttpRequest and HttpResponse Apex Class
- Ps: The problem that you can face is the size of the files. Please remember that HTTP Request size are currently limited to 100Kb of data, so larger exports would fail unless a mechanism was created to utilize multi-part transmissions.