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.
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.
Before you begin
- 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. - 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.
- From the Designer dashboard, click .
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.
- Enter a name that identifies the purpose of your flow; for example: Share Document with Salesforce Contact
- Select as the event that is to trigger the flow.
- Click the (+) and then scroll down to IBM Cloud Object Storage S3.
- Select as the action that App Connect uses to download the ‘Getting Started’ document.
- 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.
- Select the ‘Bucket’ where your document is stored on Cloud Object Storage.
- Select the Type of file as ‘binary’ since you are downloading a PDF document
- Set the Object name as the name of your ‘Getting_Started’ manual.
- 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.
- Select as the action that App Connect uses to create a folder.
- 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
- Next, create the ‘Getting Started’ manual that was downloaded from Cloud Object Storage in this folder on Dropbox
- Click the Add node icon (+) after the Dropbox Create folder node and select Dropbox.
- This time, select as the action that App Connect uses to create a file.
- 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.
- 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).
Test your flow
- Log in to Salesforce using the account that you configured in App Connect.
- Create a new Salesforce contact and save the contact.
- After a short while, check your Dropbox account for a new folder and document.
- Examine the App Connect Dashboard. If the flow ran successfully, the flow tile shows a green tick
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.