How to send and receive data from Salesforce to a FTP server

My question is how I can intergrate Salesforce with different FTP servers in real time. I have read some articles about it, but to be absolutely sure I thought it would be a good idea to post a question here.

I want to be able to send and receive data from Salesforce as a csv file to a ftp server. How I’m thinking about doing this is listed below.

Send the data:

Create a apex class which query the necessary data in Salesforce and create a csv file. I guess this is trivial? Then send the file to a web service created in Salesforce, just by calling it in the apex code.
Create a web service in Salesforce which receives the data from the apex code. This web service should in some way send the data to the appropriate ftp server. I guess I can simply modify some of the code provided by Salesforce to make this work?
The file is sent.
Receive the data

This one is a bit trickier. I guess I have to pull the data from the FTP server by using my web service, which then send the file collected to the appropriate apex class.
Or, the FTP server could send the data to the SFDC web service, I don’t know if this is possible?
The web services on the other side that sends the data to the ftp server, could send it directly to the SFDC web service, which then again forward it to the apex class. I guess the web service will use the remote site url to connect to the SFDC web service?


Through the salesforce service (Apex or others) you cannot directly communicate with an FTP server (either upload or download).

Your best bet would be to use an external application. Jitterbit Data Loader is the go to application for FTP interactions with salesforce.

You could also create your own service outside of the salesforce platform.

Source : Link , Question Author : ttveten , Answer Author : Ryan Guest

Leave a Comment