Accessing & Exporting Salesforce files to use with your other App
One of the common questions that we often get is “I have attachments or images in a document folder, how can I publish it on our website or web application?”. There are some easy ways to do it using one of our tools DBSync Cloud Replication for Salesforce.
DBSync Cloud Replication for Salesforce helps data to be synchronized between Salesforce and Database namely Oracle, SQL Server, mySQL, PostgreSQL, Apache Cassandra, DB2 and Amazon Redshift. This app can help you in building data warehouses, data migration, offline data storage for reporting and cleansing the production data. It supports both standard and custom objects in Salesforce. Images, PDF, chatter feed uploads and other content files attached within Salesforce are stored as attachments, documents and content version object files, respectively. These files can be replicated in the local directory using replication feature.
How the files are differentiated from each other after replication?
So why do our customers often ask for it. Here are some of the use cases that we encounter:
-
- Have an application that requires the picture of your customer (much like LinkedIn or Facebook)
-
- Want to expose contract agreements to a mobile app for the field service
-
- Share marketing collaterals from Documents or Content in Salesforce
-
- Share product images on your website
- Include images in marketing email or other campaigns
So how can we architect that? There are 3 ways you can access these files:
1. Use Salesforce SOAP API to call in realtime to pull the attachments. This is usually not scalable if you have lot of traffic as API’s are metered. You can get a lot of sample code to implement it from Salesforce documentations. We do not recommend just because of API governance limitation.
2. Download all attachments locally so that your other application can have all the access it needs. Its usefull specially for high access apps like Websites, you just have to plan for storage.
We will recommend using “File Replication” DBSync to show how to set it up. This feature enables you to download all the files into your local drive, at the same time update your database with the right information for your web application to refer it. Here is a quick look at the setup:
Once the file (local storage) with its file meta data (in your Database), you will see your downloaded table will be like the one below (this example is on mySQL, you can also push it to SQLServer, Oracle or any supported databases):
This is how you downloaded folder will look like:
There are many benefits of this approach, while it does not use as much API’s while keeping your Salesforce Attachment in sync with your application – web, mobile or other, it also keeps a backup of the file so that in case someone deletes the content in salesforce, your Web application might not be broken. It has capabilities for both hard and soft delete your files, giving you more control on how you want it to work.
3. Make files “Externally Available Image” in Salesforce (works only for Documents which are images) and use a link pattern to build the link to access it.
Go to Documents > select the folder > open the document to expose. It will look like this:
Note the Salesforce id for this document. Your URL will look something like https://<your-salesforce-domain/servlet/servlet.FileDownload?file=<sfId>
Here is an example:
<img src=”/servlet/servlet.FileDownload?file=01528000003Drfz” alt=”DBSync” style=”height:200px; width:200px;” border=”0″/>
TIP: While implementing this approach, we do recommend that you replicate Document Object to a local database table so that you can lookup the salesforce id (sfid) without hitting your Salesforce API
Check out our Wiki to find more ways to backup and replicate Salesforce data.
Download the Free Developer Version Now
Unleash the true potential of your Salesforce cloud data with ease. Say goodbye to hidden APIs and inaccessible information. Experience the game-changing benefits of DBSync’s innovative solution that revolutionizes data replication and delivery for your IT needs.
Step 1: Download our Developer version now.
Step 2: Effortlessly set up with our user-friendly interface.
Step 3: Seamlessly replicate Salesforce data into your database.
Step 4: Achieve unrivaled compliance and security without any hassle.