How to use Cloud Storage Connector for Dropbox with Qlik Application Automation
This article gives an overview of the available blocks in the cloud storage connector in Qlik Application Automation to work with files in Dropbox. It will provide some basic examples of listing files, opening a file, reading from a file, creating a new file, and writing lines to a file.
The cloud storage connector supports other blocks to copy files, move files and check if a file already exists that could help to cover other uses cases. It is recommended to use the blocks in this connector, i.e. Cloud Storage, when working or manipulating files. For other type of operations, such as creating a sharing link for a file, making generic calls, or getting other metadata from your account, please use the blocks available in the Dropbox connector in Qlik Application Automation.
Authentication for this connector is based on the oAuth2 Protocol. For more details check this article.
Let's now go over a few basic operations of how to use the cloud storage blocks work for Dropbox:
How to list files from a Dropbox account
Create an automation.
From the left menu, select the Cloud Storage connector
c. Search for the List Files block from the available list of blocks.
d. Drag and drop the block into the automation and connect it after the Start block.
e. The ‘Path’ parameter of this block allows to list the contents of a specific directory from a Dropbox account. In this example, ‘./’ indicates the root directory.
f. Drag and drop the ‘Output’ block into the automation and connect it to the ‘List Files on Dropbox’ block.
g. Run the automation (if not saved previously, a 'Save automation' popup will appear). This will output a paginated list of files available in the root directory of a Dropbox account.
2. How to open an existing file and read from it
a. The first two steps are similar as described before b. Now use the ‘Open File’ block from the list c. Drag and drop the block into the automation, link it to the Start block and enter the ‘Path’ to the file including the extension, e.g. ./Blendr/Monitoring_Blends.csv
d. Drag and drop the ‘Read Data From File’ and link it to the previous block. Use the output from the previous block as input.
e. Drag and drop the ‘Output’ block into the automation before running the automation. This will output a paginated table with the rows stored in the file.
3. How to create a new file (if it doesn’t exist and delete if it does), write to file, save and close file
a. The first two steps are similar as in the two previous use cases b. Now select the ‘Check If File Exists’, drag and drop it into the automation and link it to the Start block.
c. The previous block will return ‘True’ if the file exists, and ‘False’ if it doesn’t. Now search for the ‘Condition’ block to drag and drop it into the automation. Link it to the previous block and add the following condition:
d. First let’s work on the ‘YES’ part of the condition. Search the ‘Delete File’ block and drag and drop it into the automation. This will delete the file in the specified directory if it already exists.
e. Next, search the ‘Create File’ block, add it to the automation, and link it to the previous block.
f. Search the ‘Write Line to File’ block and link it to the ‘Create File on Dropbox’ block. Fill in the required input parameters. If you select CSV under ‘Mode’, the column names (headers) of the file can be added at the same time as the data rows.
g. This example shows how to add ‘Column names’ manually but, of course, these could be retrieved from other files stored in Dropbox, or objects using the Get Keys formula. Same applies to the ‘Data’ input box, values have been added manually in this example but could be read from other files on Dropbox or other cloud data sources.
h. Finally, search the ‘Save and Close’ block, and link it to the ‘Write Line to File’ block. Optionally, add the ‘Output’ block into the automation which will show the path where the file has been saved and closed on the Dropbox account.
i. Last part of the automation is the ‘NO’ condition (file doesn’t exist) which basically means adding the same blocks as before apart from the ‘Delete File’ block.
Attached downloadable example file: create_and_write_files_dropbox.json
The information in this article is provided as-is and to be used at own discretion. Depending on tool(s) used, customization(s), and/or other factors ongoing support on the solution below may not be provided by Qlik Support.