function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion

Posting data to FTP Server



I have a requirement to post  some data from SFDC to Secure FTP Server. if anybody have the idea about this please let me know.


Thanks In Advance





FTP is an interactive protocol, while the only two functions you can use (PageReference.getContent() and Http.send(HttpRequest)) are both non-interactive. Therefore, you can not currently directly upload to a FTP site. You must instead send the file to a REST-ful endpoint, and have that endpoint complete the transfer on your script's behalf.


Thanks for Response,


ok, i understand that we can not contect FTP Site directly.

Could you please explain the alternate way (sending filr to REST-ful endpoint) which you mentioned. if you use this way, how the file  would reach the FTP Site?  Could you please explain a bit clear


Thanks & Regards



Step 1: Create script on public server that generally runs like this:


1) Accepting incoming HTTP request POST.

2) Authenticate that request is from SFDC and contains valid payload.

3) Connect to FTP server.

4) Transfer file.

5) Respond with FTP error code in response payload, use HTTP status to indicate general success/failure (200, 500, 401, etc).


Step 2: Create Apex Script that contacts site from step 1.


1) Load file contents.

2) Build payload for request.

3) Send payload to server.

4) Process result.

5) Perform post-transfer logic.


Step 3: Authenticate the endpoint in SFDC.


1) In setup, you have to configure the site for step 1 as a legal endpoint.


At this point, everything will work just fine. Note that you'll be limited to about 60 seconds to transfer the file or will abort its connection. Make sure your server has enough bandwidth and is capable of transferring the file in time. You might also run the FTP connection asynchronously. It's possible to write a script that can call the API back when the FTP transfer is complete. I highly recommend using HTTPS if you do this, because your session key would be in cleartext otherwise.

Hi Have you got any sloution to do it? Currently I am trying to upload a csv from sfdc to FTP.
You can export a CSV file from SFDC to FTP with help of Skyvia. It`s a cloud-based solution which allows you easily set up data import in simple GUI and with flexible scheduling features.

Here you can find more about it:
You can use below FTP API to integrate FTP server with Salesforce.

We have implemented a REST API which allow to directly communicate with an FTP server. This FTP API is designed for people who need to perform actions like DOWNLOAD, UPLOAD, DELETE and TRANSFER on the FTP server using REST API’s.

Blog Post:

Please let me know if you need any other information.