Managing files with Google Drive - 6.3

Talend Open Studio for Big Data Components Reference Guide

EnrichVersion
6.3
EnrichProdName
Talend Open Studio for Big Data
task
Data Governance
Data Quality and Preparation
Design and Development
EnrichPlatform
Talend Studio

This scenario describes a Job that uploads two local files to an empty folder Talend in the root directory of Google Drive, then creates a new folder Backup in the folder Talend and copies a file to the Backup folder, and finally lists and displays all files and folders in the root directory of Google Drive on the console.

Prerequisites:

  1. A Google account has been created and the access token that gives authentication for your request has been generated. For how to get the access token, see Obtaining an access token for Google Drive.

  2. An empty folder Talend has been created in the root directory of Google Drive.

Adding and linking components

  1. Create a new Job and add the following components by typing their names in the design workspace or dropping them from the Palette:

    • a tGoogleDriveConnection component,

    • two tGoogleDrivePut components,

    • a tGoogleDriveCreate component,

    • a tGoogleDriveCopy component,

    • a tGoogleDriveList component,

    • a tIterateToFlow component, and

    • three tLogRow components.

  2. Link tGoogleDriveCreate to the first tLogRow using a Row > Main connection.

  3. Link tGoogleDriveCopy to the second tLogRow using a Row > Main connection.

  4. Link tGoogleDriveList to tIterateToFlow using a Row > Iterate connection.

  5. Link tIterateToFlow to the third tLogRow using a Row > Main connection.

  6. Link tGoogleDriveConnection to the first tGoogleDrivePut using a Trigger > On Subjob Ok connection.

  7. Do the same to link the first tGoogleDrivePut to the second tGoogleDrivePut, link the second tGoogleDrivePut to tGoogleDriveCreate, link tGoogleDriveCreate to tGoogleDriveCopy, and link tGoogleDriveCopy to tGoogleDriveList.

Configuring the components

Opening a connection to Google Drive

  1. Double-click tGoogleDriveConnection to open its Basic settings view in the Component tab.

  2. In the Application Name field, enter the application name required by Google Drive to get access to its API. In this example, it is TalendProduct.

  3. In the Access Token field, enter the access token required by Google Drive to access a Google Drive account.

Uploading files to Google Drive

  1. Double-click the first tGoogleDrivePut to open its Basic settings view in the Component tab.

  2. Select the Use Existing Connection check box and from the list that appears select the component you have configured to open your Google Drive connection. In this example, it is tGoogleDriveConnection_1.

  3. Select the Upload Local File option button and in the File field, browse to or enter the path to the file to be uploaded. In this example, it is C:/Talend/Talend Release Plan.csv.

  4. In the File Title field, enter the name for the file after being uploaded. In this example, it is Talend Release Plan.csv.

  5. In the Destination Folder Name field, enter the name of the folder in which the file will be stored in Google Drive. In this example, it is Talend.

  6. Double-click the second tGoogleDrivePut to open its Basic settings view in the Component tab.

  7. Repeat Step 2 through Step 5 to upload another local file to the folder Talend in Google Drive. In this example, it is Talend Products.txt.

Creating a new folder in Google Drive

  1. Double-click tGoogleDriveCreate to open its Basic settings view in the Component tab.

  2. Select the Use Existing Connection check box and from the list that appears select the component you have configured to open your Google Drive connection.

  3. In the Parent Folder Name field, enter the name of the folder in which a new folder will be created. In this example, it is Talend.

  4. In the New Folder Name field, enter the name of the folder to be created. In this example, it is Backup.

  5. Click the [...] button next to Edit schema to view the predefined schema of tGoogleDriveCreate.