+ Start a Discussion
Nagaraj SVNagaraj SV 

Transfer files to FTP from Salesforce Attachment object

Can any one help me how to Transfer files to FTP from Salesforce Attachment object.
You could do this with a cron script (or somthing simliar) and POST it via the REST api [1].  If you have any specific questions or problems with the implementation, please don't heasitate to ask.

[1] https://developer.salesforce.com/docs/atlas.en-us.api_rest.meta/api_rest/
Nagaraj SVNagaraj SV

Hi pcon,

Thank you for quick response . If i want to send file from Salesforce to FTP .

I have couple of questions 

1.Do we need to run any service at FTP?

2.What is the end point ?

You'll need to run something on the FTP server that will push the newly created files to Salesforce. (Something like this [1] may help you get started monitoring the FTP server *).

The endpoint would be the standard REST endpoint [2] for the Attachment object and you would just provide the fields required [3]

There are some limitations around attachments in Salesforce that you do need to be mindful of [4].  Because of those limitations you may want to consider linking to the FTP resource in a way that your users can reach (either expose it via HTTP as well or make it easy for your users to interact with FTP).  Once exposed you could create a custom Attachment object that contains the link to the resource and is linked to the appropriate object.  This way you do not use up storage space in Salesforce.

* Some FTP servers will allow you to run commands after a file is finished uploading.  That would be up to you to figure out if your FTP server will allow that.

[1] http://blog.deadlypenguin.com/blog/2012/12/19/auto-watch-a-directory-and-rebuild-the-repo/
[2] https://developer.salesforce.com/docs/atlas.en-us.api_rest.meta/api_rest/dome_sobject_create.htm
[3] https://developer.salesforce.com/docs/atlas.en-us.api.meta/api/sforce_api_objects_attachment.htm
[4] https://help.salesforce.com/apex/HTViewHelpDoc?id=collab_files_size_limits.htm
Keith WalkerKeith Walker
You can automatically transfer your Salesforce Attachment objects to FTP (or any type of Storages) with the help of Skyvia (https://skyvia.com/data-integration/integrate-salesforce-ftp). It is web-based ETL service with simple UI and flexible scheduling options.
Massimiliano CiarroccaMassimiliano Ciarrocca
Hi Keith, I'm trying Skyvia. Do you know what's the name ofe the object where I can find all the attachment in SalesForce? I would like to backup all the images attached to my Service Appointmens.
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.

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.