Sync Objects from Google Cloud Storage Bucket to Google Drive

Summary:

This article describes one business use case integration where an object content of a Google Cloud Storage bucket will be uploaded to Google Drive using resumable upload.

Prerequisites:

The user needs to have a working Google account and a working webMethods.io tenant.

Contents:

This use-case describes the step-by-step process of integration between Google Cloud Storage and Google Drive, where an object content is retrieved from a Google Cloud Storage bucket and the same is uploaded to Google Drive using resumable upload. This example will also show the mapping steps in the new webMethods.io flow service.

Note: Any coding or configuration examples provided in this document are only examples and are not intended for use in a production system without verification. The example is only done here to better explain and visualization of the possibilities.

Steps:

1. Login to the webMethods.io, create a new project. Then choose the ‘FlowServices’ tab, click on ‘+’ icon to create a new flow service.

2. Give some name to the flow service, then add the Google Drive connector.

3. Select the predefined action ‘getResumableSession’ from the dropdown menu.

Note: This step is required to retrieve the ‘upload id’ required to perform the resumable upload. However, this step doesn’t imply if the simple upload is selected.

4. Once the action is selected, the connection should be created. Accounts can be created by selecting either of the 'default' or 'manual' option from the dropdown.

Note: For more details on how to configure a google account, please refer to this article below:

https://techcommunity.softwareag.com/pwiki/-/wiki/Main/Google%20OAuth%202.0%20Connection%20in%20webMethods.io

5. Once the account is configured, add a ‘try’ block and insert an ‘if’ condition inside it. Inside ‘if’ condition validate ‘getResumableSessionOutput’ response. A not null scenario can be checked as shown in the screenshot below.

5.1. The ‘if’ block has two cases, YES or NO. The flow of execution will proceed based on this ‘if’ block condition evaluation.

5.2. Inside the YES path add the ‘Google Cloud Storage’ connector. Configure the ‘Google Cloud Storage’ account in the same manner as Google Drive connector above.

 5.3. Then, select the predefined action ‘getObjectsContent’ from the dropdown menu.

5.4. Add one more step to add an ‘if’ block inside the previous ‘if’ block to validate the ‘getObjectsContentOutput’ response. A not null scenario can be checked as done in previous steps.

5.4.1. Inside the ‘YES’ path of this ‘if’ block, add the ‘Google Drive’ connector. Select the ‘uploadFile’ predefined action and the ‘Google Drive’ account created earlier.

5.4.2. Add an ‘else’ block to this ‘if’ block. Add ‘Exit’ signaling ‘Failure’ with the message ‘Error getting objects content from the bucket’ inside this 'else' block. If ‘getObjectsContentOutput’ response is null, the flow of execution will go inside this ‘else’ block.

5.5. Now, add an ‘else’ block to the previous ‘if’ block. Add ‘Exit’ signaling ‘Failure’ with the message ‘Error getting resumable session’. If ‘getResumableSessionOutput’ response is null, the flow of execution will go inside this ‘else’ block.

6. Add an ‘Exit’ step signaling ‘Success’ at the end. If none of the above ‘else’ blocks are executed, it will exit with success.

7. Add a catch block and select ‘GetLastError’ service under ‘Flow’, that informs the user for any errors that occurred during the flow service execution.

8. Now go to 'i/o' tab at the top right corner and add all the data fields required for the integration execution. For example, bucketName, object, uploadType, filename etc.

9. Select the ‘Edit Mapping’ option at the right corner for ‘GetResumableSession’ action and map the 'Pipeline Input' fields to it as shown below.

10. Similarly, go to ‘Edit Mapping’ for ‘GetObjectsContent’ of Google Cloud Storage and ‘uploadFile’ of Google Drive and map the 'Pipeline Input' fields as shown below.

11. Run the flow service, it will ask for the pipeline inputs. Provide the inputs and click ‘Run’.

12. Once the Flow service executed successfully, the result will be visible in the result screen at right.

13. The file with the same name provided as input is uploaded to Drive. Download the file for preview.