Skip to content

Upload Files to Cloud Storage from Salesforce Using CloudFiles

Upload Files to Cloud Storage from Salesforce Using CloudFiles.

1. Introduction

Salesforce file storage cost is high. Using an external cloud storage such as Google Drive, OneDrive or SharePoint makes the most sense for businesses. While there are multiple tools to do this, including Salesforce’s own Files Connect, they are still not very easy and intuitive to setup and use.

CloudFiles is a highly integrated Salesforce app that makes this process easy. CloudFiles provides an easy to setup widget, to view the live library in a dialog on Salesforce objects and upload files into them. The app also provides various flow actions that can be used to do this automatically. Moreover, since it’s an external application, it bypasses governor limits.

Read this article to understand the CloudFiles app, connect & set it up and use it to upload files to any cloud storage.

CloudFiles Introduction

2. Installation & Setup

To follow along with this tutorial, you must first install the CloudFiles application in a sandbox environment to test it out. The app provides a free trial period and more trial days can be requested to continue testing.

2.1 Installing the CloudFiles App

To install the app, simply follow the below steps –

  1. Login to your Salesforce account as a Salesforce Admin.
  2. Go to the CloudFiles listing on the Salesforce AppExchange, and click on Get It Now.
  3. Follow the prompts to install the app. You can either choose production or sandbox.
  4. At separate points during the installation, the installer asks you to:
    • Accept and Approve Third-Party Access for remote settings.
    • Grant access to all users.
    • Click Next or Continue in other screens to complete the installation.

If you need help with these steps, you can refer to the detailed CloudFiles Salesforce Setup guide here which has screenshots to some of these steps as well.

Now that the app is installed, we are ready to set up the LWC.

2.2 Setting up the CloudFiles Widget

CloudFiles provides a lightning web component(LWC) to make it easy to connect to your cloud storages from all standard & custom Salesforce objects. You can drag n drop the LWC onto any standard or custom Salesforce object.

We will be adding the LWC on the contact objects. The steps are covered below –

  1. Go to any contact object where you’d like to upload files from.
  2. Click on top right Setting icon > Edit Page button
  3. Add a new custom tab and name it as per your requirement
  4. Drag and drop the ‘CloudFiles Attachment LWC’ onto your new tab
  5. Click Save and Activate

These steps are summarized in the GIF below –

Setting up CloudFiles

2.3 Creating CloudFiles Account

Now go to the the contact object, locate the LWC and click on the Connect button. This will guide you through a quick CloudFiles account creation / selection process after which you should be all setup.

Check the GIF below for the account creation process –

Creating CloudFiles Account

All done. Now that you have the CloudFiles LWC connected, you can login to your cloud storage through CloudFiles and start working with your files.

2.4 Connecting Cloud Storage

Connecting a cloud storage is a one-time, one-click process. For the sake of this tutorial, we will connect our google drive library. Follow the simple steps below to connect the library –

  • Go to any contact object
  • Locate the CloudFiles LWC and click on the “Add File” button
  • Select the google drive library from the left sidebar.
    • In case you don’t see the Google Drive option, click on the little gear icon on top left and unhide the Google Drive option.
  • Click the connect google drive button. Standard google login process will follow.
  • Your files should start showing up immediately
    • You can try closing / opening the dialog again in case it does not refresh by its own.
Connect your Google Drive Account

Now that you have your library connected, you can easily upload files into these storages. This can be done either manually, or automatically. We cover both these scenarios below.

3. Uploading to Cloud Storage from Salesforce Using LWC

To manually upload files in a specific folder on a cloud storage, we will use the CloudFiles’ lightning web component. This is the same component in which we logged in, in the step above.

Follow these simple steps to upload your first file into Google Drive from Salesforce using CloudFiles LWC –

  • Locate the LWC and click the add files button
  • Make sure Google drive is selected on the left hand side and you are logged in.
  • Navigate to a folder where you’d like to upload a file.
  • Click the Upload button on the top right of the dialog
  • Select a file from your local storage

The file will automatically get uploaded. It will also start showing up in the dialog, as well as in your google drive. This is summarized in the graphic below.

Uploading to Cloud Storage

You can even go one step further and ‘attach’ the file on the Salesforce object. This does not transfer the file from Google drive, but only creates a reference for it on the CloudFiles LWC. This can be later used to download or edit the latest version of the file.

CloudFiles provides another widget called “Connected Folder” which can help associate single folders and view all contents of those in a widget. You can even search, upload, modify and go to cloud storage directly from the widget. Check this article to know more about connected folder widget.

Keep reading to see how file uploading can be done automatically using Salesforce flows. Scroll to the button to check out what other capabilities CloudFiles offers.

4. Upload to Cloud Storage from Salesforce Using Flows

CloudFiles provides pre-packaged flow actions and flow templates which make file related automations easy to do in Salesforce. You don’t need to know Apex to use CloudFiles automations. Although, knowing apex can always provide additional layers of customization.

In this section, we will cover a pre-packaged flow action offered by the CloudFiles app that can upload any file size or file type to any cloud storage without writing even a single line of apex.

For this example, we will be creating a custom button on contact pages that triggers a flow. This flow pulls in all the files from the notes & attachments section of the contact and uploads it to a specified folder in SharePoint.

This flow has 3 parts to it. First, we get the list of content documents we want to send. We then create a collection variable storing only the IDs of these objects. We finally pass this to the CloudFiles file upload action, along with some other parameters which sends these files to SharePoint.

4.1 Create Flow & Custom Button

First, let’s create a barebone flow and a custom button which triggers the flow and passes the record ID to it. Follow the simple steps –

  • Create an auto-launched flow.
  • In the left sidebar, add a new variable.
  • Check the image below for the values in this dialog.
  • Now go to Setup > Object Manager > Contact > Buttons, Links & Actions and create a new button
  • Check the image below for the values of this button
Create CloudFiles Flow

4.2 Get the Files to Transfer

Now that our button and flow is se tup, let’s get the attachments associated with the triggered record. These are stored in the Content Document Link Object of Salesforce. Follow these steps –

  • Add “Get Records” action to your flow
  • Select parameter in the dialog as shown below
  • This gets all the ContentDocumentLink Objects associated to the triggered record
CloudFiles File Transfer

4.3 Create Document ID Collection Variable

Now let’s convert this record collection into a string collection of IDs that can be passed to the CloudFiles upload action later. Follow these steps –

  • Create a new variable called ContentDocumentIds. See image below for dialog values.
  • Add a loop action. Select the output of Get Records as the iterator.
  • Add a single action inside the loop that adds the object’s ID to the ContentDocumentIds collection we created above. Check the image below.
Create Document ID Collection Variable

4.4 Add the CloudFiles Upload Action

Finally, we will add our CloudFiles upload action and specify where to transfer the files in Sharepoint. Follow these steps –

  • Add an action and search for upload
  • In the dialog box that opens, set the library to ‘sharepoint’
  • Set Content Document IDs to the collection variable of same name we had created in previous step
  • You will need the site ID, drive ID & folder ID using the CloudFiles app. Check this article to see how to obtain these.

Here’s how our CloudFiles upload action finally looks

dd the CloudFiles Upload Action

4.5 See it in Action

That’s it, now that our flow is ready, we can test this out. Checkout the GIF below where we trigger this flow and have our attachments transfer to SharePoint.

See it in Action

6. Additional CloudFiles Features

Although we demonstrated CloudFiles’ ability to upload files easily from Salesforce to different cloud storages, there are many other applications for the tool as well.

You can use the CloudFiles’ LWC to attach files & folders from cloud storages to objects. You can download the latest versions right from Salesforce. The LWC also provides an easy way to open the file online for editing, right in the Google or Microsoft online editors.

CloudFiles really excels in file sharing. You can create a publicly shareable link of the file that can only be viewed, and not edited, in the browser. This link can be shared with external stakeholders such as leads, customers, vendors, contractors etc…

Additional security settings such as disabling download or adding an email authentication can be added on top of the link. You can also collect analytics and automate processes using the app.

For additional information please check out the CloudFiles website here.

Written By…

Disclaimer: The views and opinions expressed in this article are solely those of the author and do not reflect the views of does not endorse any of the Third Party Organizations or Applications mentioned in the article, including their legality, integrity, quality, accuracy or any applicable intellectual property rights.

Recommended Articles


Share this article...

Please Leave a Comment

error: Content is protected !!

Discover more from DYDC

Subscribe now to keep reading and get access to the full archive.

Continue reading