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
DcoderDcoder 

FTP from salesforce

Hi,

 

We have a requirement to send attachments to a FTP server from our Prod org. I was reading about many app exchange apps like FTP attachments. As I understand, it can be used to attach files and store it on our storage server. But our requirement is send existing attachments to our FTP server. We want to have this process scheduled too like every 5 mins.

 

Please help me if we have any app which can do it or Can I do any customization in our org to achieve this. For example, we have HTTP commands in salesforce, on the similar lines Do we have for FTP?

 

thanks!

sfdcfoxsfdcfox

There isn't a way to open "sockets" in Apex Code, only "HTTP connections". The difference is that HTTP is a clean one-message-per-direction communication, such as:

 

 

GET /helloworld.txt HTTP/1.1
HOST: localhost

HTTP/1.1 200 OK
Content-Type: text/plain; charset=utf-8
Date: Fri, 13 May 2011 19:50:00 GMT
Content-Length: 12

Hello World!

Where the italic text is the client's request, and the underlined text is the server's response. FTP, in contrast, is a back-and-forth mechanism that traverses two ports (known as the command-port and data-port). A client needs the ability to converse back and forth across two simultaneous connections with the server in order to transfer files. If Apex Code had a reasonable Berkeley socket API (connect, send, recv, etc), it would be feasible to construct an FTP transfer mechanism.

 

However, there isn't such an API. I believe that such FTP attachment programs on the AppExchange work through the use of Java Applets, Flash Applets, third-party servers, and/or custom software to be installed locally. The only way you can schedule an FTP transaction every few minutes is through an external server. Your own company's web site might be a good candidate.

 

How I would do this: create a Web Service that is hosted on your company's public server(s). Have it query every few minutes, using an administrative or dedicated login, using the replication API and/or a general SOQL to find attachments that have been uploaded since the last successful query. Once this is done, connect to FTP and send the data to the FTP server.

 

paul-lmipaul-lmi

in addition, you can't schedule anything whatsoever on teh platform to run every 5 minutes.

eyewellseeyewellse

It IS possible to schedule scheduled jobs every X minutes.

see this link

sfdcfoxsfdcfox

As far as I recall, the scheduler is only accurate to every 15 minutes, even if you schedule it in a smaller window. Besides, you'd still be limited to the ~200 or so calls per day limit (you'd need 288 calls per day at 5 minute intervals). The primary concern is the lack of FTP access. You'd have to call an external server integration to initiate the FTP transfers.