Connector Tutorial Scenario 4: Process File¶
Processing an XML File from Dropbox and Writing It to an FTP Server¶
This scenario demonstrates the use of a Dropbox Process File activity. In this example, an XML file is fetched from Dropbox and then written to an FTP server as a JSON file. Similar to Scenario 1: Fetch File, the file is processed based on an XSD that is specified in the configuration of the activity in Cloud Studio.
For this, you’ll need in your Dropbox account an appropriate XML file that matches one of the XSDs included in the Dropbox connector. Sample files (
customer.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 three sample files (
customer.xml) from the
assets/sample-data directory of the Dropbox connector to 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 Process File Activity to an Operation¶
Drag a Dropbox Process File activity from the component palette to a new operation on the design canvas.
Enter into the configuration a name (such as “Process File”), the folder path (you can use the default of
/), and the name of the file to be downloaded (
Click Next to go to the next step.
With the “Dropbox Process 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” row, as that will use the XSD associated with the account XML file:
Click Next to review the data schema, showing that the response from Dropbox will be an account object and its fields. At this point, you can go back to the previous screen and try selecting the other object types to see how the data schema changes to reflect the chosen object. When finished, make sure that you have selected the account object, as that will be required for the rest of the tutorial:
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 Process File” activity.
Configure it with a name (such as
Write Process), a path (such as
/), and an appropriate filename (such as
account.json or, for a date-stamped filename,
dropbox_process_results_[date]_[time].json). The “FTP Write” activity will look like this:
You will need to specify a schema for the Write activity. The simplest way is to provide the desired output file as a sample schema. Select Yes, Provide New Schema:
You can provide the schema in a number of ways: loading a URL, uploading a file, or typing or pasting directly in the editor:
You can provide a URL; the
account.jsonfile is available at
You can also upload a file directly; the
account.jsonfile is included in the
You can also type or paste directly into the schema editor.
When complete, the schema should be similar to 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 and use Automap Exact Matches to complete the transformation mapping. If an appropriate schema was provided, all fields will automatically be mapped and the target (right) schema will indicate that the schema is JSON by the labeling of the root node. When completed, the transformation should look like this:
6. Run the Operation¶
Deploy and run the operation. The sample file should be retrieved from Dropbox, processed into a JSON format, and then placed on the FTP server. In the operation log, you should see a log message that the operation was successfully completed. On the FTP server, you should find that a copy of the file with the correct schema.