You need to sign in to do that
Don't have an account?
asadim2
FTP file stream
I am pretty sure Salesforce doesn't support this in Apex -or does it?! If not then does that mean I have to use the Streaming API? But that would involve Visualforce, and I'm hoping to find a solution only in Apex.
Thanks!
There's no enough details here, so why don't you elaborate and see if we can't find a way to help you.
I see. I want to stream a text file off of a FTP server, parse it, put the results into a record, and insert it.
Also a related question; what options do I have for sending files to an external file server? I am looking for alternatives to DataLoader (export and email).
P.S. I'm glad it's sfdcfox helping out here! It's good to have confidence in the answer you are getting :)
For accessing files from an FTP server, you'll have to use a proxy. I've been meaning to write one of these myself, but I've not had an opportunity to do so. Here's how it would be laid out:
1) External HTTP-FTP or SOAP-FTP proxy waits for Apex Code to connect and request a file.
2) Apex Code calls request to the proxy.
3) Proxy calls the FTP and retrieves the file.
4) Proxy returns the file via HTTP back to Apex Code.
5) Process the data as normal in Apex Code.
For sending files to an external server, you can basically do anything you could do with a normal HTTP or SOAP connection. For example, you could set up a form on a server, and have it accept a POST from salesforce.com, and submit that data to the external file server. You could also use a web service that was designed to accept connections and forward them to FTP servers. You can also use salesforce.com's email messaging capabilities to craft an email that could be sent to a server somewhere; the server could pick off the attachments and store them on a server.
In short, there are a ton of different options available. I'll see if I can't craft a FTP proxy, it looks like it should be deadly simple using PHP. I've bookmarked this post so I don't lose it; if I come up with something, I'll let you know.
In the meantime, let me know if there's anything I can do to help point you in the right direction. File access is fairly trivial once everything is in place.
P.S. Thanks for the vote of confidence!
Fantastic Mr. Sandwich! In the meantime I will start by looking into the SF Ajax Proxy. I may come back to this post if I hit a brick wall.
Also please do share your FTP proxy if you manage to write it. Proxy is a scary thing to me!
Thanks again!
Btw I'm assuming I need a proxy only because Remote Site Settings does not support FTP sites, right?
C: <ACTION> <PATH> <HTTP-VERSION>
C: <HEADERS>*
S: <HTTP-VERSION> <STATUS> <STATUS-TEXT>
S: <HEADERS>
S: <CONTENT>
While a FTP connection is more like:
S: <GREETING>
C: <USER-COMMAND>
S: <ACKNOWLEDGE>
C: <PASSWORD-COMMAND>
S: <ACKNOWLEDGE>
C: <CHANGE-DIRECTORY>
S: <ACKNOWLEDGE>
C: <GET-FILE-COMMAND>
S: <SENDS-FILE>
This interactivity makes the REST interface useless. What you need is a system that proxies this request, abstracting the interactivity from Apex Code and exposing the functionality as a non-interactive interface.
Hello, I'm replying to this to see if you were able to find a solution. We are basically in the same boat. We would like to download media files through an FTP server using Salesforce. Since there is a limit of 3MB on webservice calls, I wanted to know if it's possible to use the Ajax toolkit to download the file.
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.