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?
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.