I have a requirement from one of my client where they want to send Contact and its related object data to there local server in CSV format. The want to establish a FTP connection so that file can be directly transferred to a fixed location on there server.

I am able to create the CSV file within APEX code, however not sure how to send out a file.

One option can be to create an multipart HTTP request and send the file as the body, however they do not have any service setup to consume the request.

Is it even possible to transfer a file directly from Salesforce to a server location without any service setup?

2 Answers 2


You can't directly access FTP in Apex Code, because FTP requires interactive sockets and multiple ports (not to mention the FTP port isn't available for call outs). You will need an intermediary to translate the request into something that can connect to the FTP server. For example, you could write a SOAP service you could call to send the file to the FTP server. Or an email client that watches a certain address. Or some REST device that can do this.

I've had a proxy like this on my bucket list, but I haven't had the time yet to build it. It should be relatively trivial though, for a competent developer in any one of the multitude of languages that this could be developed in.


I was also in similar situation and solved it using ANT. In case someone need other approach - please refer this article on how Dataloader can be used to save csv file on FTP server with little help of ANT.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .