You need to sign in to do that
Don't have an account?
SomeswaraRao.V
Posting data to FTP Server
Hi,
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
regards
Somes
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
Somes
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 salesforce.com 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.
Here you can find more about it: https://skyvia.com/data-integration/integrate-salesforce-ftp
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.
FTP API: https://ftp-api.herokuapp.com/
Blog Post: https://medium.com/@adarshsharma.jaipur/how-to-use-ftp-server-using-rest-api-8d1b3f88de0
Please let me know if you need any other information.