Connector Tutorial Scenario 5: Get File¶
Getting a File (JSON or XML) from Dropbox and Writing to an FTP Server¶
This scenario demonstrates the use of a Dropbox get file activity. In this example, a file (JSON or XML) is fetched from Dropbox and then written to an FTP server. Similar to Scenario 4: Process File, the file is dynamically specified during the configuration of the activity in Cloud Studio by reading the directory contents of the Dropbox folder.
This is unlike the Dropbox process file activity of the previous scenario, where the filename and the schema used to process the file are specified separately, and the available schemas are pre-defined in the connector.
For this, you’ll need in your Dropbox account appropriate JSON and XML files. Sample files (JSON and XML) for this
purpose are included in the
assets/sample-data directory of
the Dropbox connector source files.
Here is the completed operation:
1. Copy Sample Files to Dropbox¶
Copy the sample files from the
assets/sample-data directory of
the Dropbox connector to the root directory of your Dropbox account.
2. Create a New Workflow¶
Start with a new workflow in the current project. You can reuse components from the previous scenarios, but a new workflow makes it easier to keep the operations separate.
3. Add a Dropbox Get File Activity to an Operation¶
Drag a Dropbox get file activity from the component palette to a new operation on the design canvas.
Enter into the configuration a name (such as “Get File”) and the folder path (you can use the default of
/ if you
placed the sample data files in the root directory of your Dropbox account):
Click Next to go to the next step.
With the “Dropbox Get File” activity, we are demonstrating the ability of a connector to dynamically configure the schema based on a user selection. The schemas available are included in the connector at build time, but a connector could dynamically refresh the list and available connectors. Select the “account.json” row, as that will use the XSD associated with the account JSON file:
Click Next to review the data schema, showing that the response from Dropbox will be a JSON object and showing its
fields. At this point, you can go back to the previous screen and try selecting the other file types to see how the
data schema changes to reflect the chosen file. When finished, make a note of which file you have selected; we’ll show
the tutorial using the
Click Finished to close the activity configuration.
4. Add an FTP Write Activity to the Operation¶
Using the FTP endpoint called “FTP” you configured for this tutorial (see Tutorial Scenarios in Dropbox Connector Tutorial), drag an FTP write activity to the operation just after the “Dropbox Get File” activity:
Configure it with a name (such as
Write Get), a path (such as
/), and an appropriate filename pattern (such as
dropbox_get_results_[date]_[time].json). The “FTP Write” activity will look like this:
Click Next and then Finished to return to the workflow.
5. Add a Transformation to the Operation¶
Add a transformation between the two activities.
When it opens, give the transformation a name (such as “Get to FTP Write”), use Mirror Source Schema, and then Automap Exact Matches to create the transformation mapping. When completed, the transformation should look like this:
Then return to the workflow.
6. Run the Operation¶
Deploy and run the operation. The selected file should be retrieved from Dropbox and written to the FTP server with a name based on the pattern. In the operation log, you should see a log message that the operation was successfully completed.
You can now revise the operation and try other sample files (JSON or XML) and see that they are processed in a similar fashion.