Downloading a file from IBM Cloud Object Storage to a Dropbox folder

Learn how an event-driven flow can automatically download a file from IBM Cloud® Object Storage when a new contact is created in Salesforce. The flow can then send the downloaded file to a specific folder in Dropbox.

IBM®'s Cloud Object Storage S3 is ideal for holding large amounts of production data, such as backups and archives, and large files, such as video files and genomic data. Cloud Object Storage is a reliable, durable, and resilient object storage service.

Note: To complete this tutorial, you need to have free, trial, or business accounts with Dropbox, Cloud Object Storage, and (if needed) Google.

Scenario

This scenario uses Salesforce to manage customers and Cloud Object Storage to store some related documents. The scenario also uses Dropbox to share files in folders that are specific to users. When a new contact is created, you want to create a folder in your Dropbox account and send a "getting started" document to this contact. The getting started document is a PDF file that is stored in your Cloud Object Storage account.

Figure 1. An event-driven flow to download a document from Cloud Object Storage when a new contact is created in Salesforce and upload that document to Dropbox
Event-Driven flow to download a document from IBM Cloud Object Storage when a new contact is created in Salesforce and upload that document to Dropbox.

Before you begin

  1. Find the following account details that you need to connect App Connect to your applications.
    • For Salesforce, you need a user ID and password to connect. If you want to create a free Salesforce account to test out App Connect, make sure that you create a Developer account rather than a Trial account. For more information, see How to use IBM App Connect with Salesforce
    • To connect to a Cloud Object Storage account, you need the following values that can get from the "Endpoint" and "Service Credentials" pages in the side navigation of your Cloud Object Storage dashboard.
      Enpoint URL
      Find the Cloud Object Storage Endpoint PUBLIC or PRIVATE URL value for your region; for example, s3.us.cloud-object-storage.appdomain.cloud (PUBLIC URL for the us-geo region)
      Secret access key
      Go to Cloud Object Storage Service credentials, then View credential (with HMAC), then cos_hmac_keys/secret_access_key.
      Access key ID
      Go to Cloud Object Storage Service credentials, then View credential (with HMAC), then cos_hmac_keys/access_key_id.
      Region
      Go to Cloud Object Storage Endpoint, then select the value of Location; for example, us-geo.
      Note: To get a secret access key and Access Key ID, you need to create a credential with the option to generate HMAC credentials. (When you add a credential, specify {"HMAC":true} in the field Add Inline Configuration Parameters (Optional). For more information, see Service credentials in the Cloud Object Storage documentation.
      Figure 2. Credential with HMAC keys on Cloud Object Storage console
      Credential with HMAC keys on IBM Cloud Object Storage console
    • You can create a connection to Dropbox either by using a Dropbox user ID and password or by using a Google account.

Create your flow

By using App Connect Designer, you can create your flow from a template or from scratch if you want to explore the steps that are taken to create a flow.

Complete the following steps in App Connect Designer.

  1. From the Designer dashboard, click Create > Event-driven flow.

    Complete the following steps. As you progress, App Connect automatically saves your changes. If you move away from the flow at any stage, the flow is saved as a draft flow that you can complete at another time.

  2. Enter a name that identifies the purpose of your flow; for example: Share Document with Salesforce Contact
  3. Select Salesforce > New contact as the event that is to trigger the flow.
  4. Click the (+) and then scroll down to IBM Cloud Object Storage S3.
  5. Select IBM Cloud Object Storage S3 > Download object as the action that App Connect uses to download the ‘Getting Started’ document.
    Figure 3. Cloud Object Storage Download object action
    IBM Cloud Object Storage Download object action
  6. If you have not connected App Connect to Cloud Object Storage, click Connect and then complete and submit the request by using the account details that you obtained previously.
    Figure 4. Specify details to connect to Cloud Object Storage
    Specify details to connect to Cloud Object Storage
  7. Select the ‘Bucket’ where your document is stored on Cloud Object Storage.
    Figure 5. Download the object from Cloud Object Storage
    Download the object from IBM Cloud Object Storage
  8. Select the Type of file as ‘binary’ since you are downloading a PDF document
  9. Set the Object name as the name of your ‘Getting_Started’ manual.
  10. For the next node, click the (+) after the IBM Cloud Object Storage S3 node and scroll down to the Dropbox.

    You next create a folder for the new Salesforce contact.

  11. Select Dropbox > Create folder as the action that App Connect uses to create a folder.
    Figure 6. Create a folder on Dropbox
    Create a folder on Dropbox
  12. Set the Path field to uniquely identify a folder for the contact. For an example, you can create a folder with the given name and surname of the contact, and separate them with an underscore. The value is mapped from the New contact field of the Salesforce node into the Path field of the Dropbox Create folder action
  13. Next, create the ‘Getting Started’ manual that was downloaded from Cloud Object Storage in this folder on Dropbox
  14. Click the Add node icon (+) after the Dropbox Create folder node and select Dropbox.
  15. This time, select Dropbox > Create file as the action that App Connect uses to create a file.
  16. Set the following values for the fields in the Create file action.
    • For the Path, map the given name and surname (which are separated by an underscore) to the Salesforce New contact field.
    • Map the File content field to the Object content from the Cloud Object Storage Download object.
    • Set Auto rename to false because the file is being created for the first time.
    • Set Mute to false.
    • Set the FileName field to the name of your getting started document (for example, Getting_Started.pdf).
    • Set Is text to false because you're uploading a PDF file.
    Figure 7. Create a file in the folder created on Dropbox
    Create a file in the folder created on Dropbox
  17. To test the flow, click Start flow, then click Dashboard to exit the flow editor. Your flow is displayed on your Designer dashboard and is listening for your event (the addition of a new contact in Salesforce).
    Figure 8. The flow tile on the Dashboard, showing that the flow is running and listening for events
    The flow tile on the Dashboard, showing that the flow is running and listening for events

Test your flow

  1. Log in to Salesforce using the account that you configured in App Connect.
  2. Create a new Salesforce contact and save the contact.
    Figure 9. Creating a contact in Salesforce
    Creating a new contact in Salesforce
  3. After a short while, check your Dropbox account for a new folder and document.
    Figure 10. Document created in the folder on Dropbox
    Document created in the folder on Dropbox
  4. Examine the App Connect Dashboard. If the flow ran successfully, the flow tile shows a green tick
Figure 11. Flow tile on the Dashboard, showing the last successful run
Flow tile on the Dashboard, showing last successful run

Conclusion

You created a flow that is triggered when a new contact is added to Salesforce. The flow downloads a document from Cloud Object Storage, creates a folder on Dropbox, and places the downloaded document in the folder.