tGoogleDrivePut - 6.1

Talend Components Reference Guide

EnrichVersion
6.1
EnrichProdName
Talend Big Data
Talend Big Data Platform
Talend Data Fabric
Talend Data Integration
Talend Data Management Platform
Talend Data Services Platform
Talend ESB
Talend MDM Platform
Talend Open Studio for Big Data
Talend Open Studio for Data Integration
Talend Open Studio for Data Quality
Talend Open Studio for ESB
Talend Open Studio for MDM
Talend Real-Time Big Data Platform
task
Data Governance
Data Quality and Preparation
Design and Development
EnrichPlatform
Talend Studio

tGoogleDrivePut properties

Component family

Cloud / Google Drive

 

Function

This component uploads data from an input data flow or a local file to Google Drive.

Purpose

This component allows you to upload data to Google Drive.

Basic settings

Use Existing Connection

Select this check box and from the list that appears select the relevant connection component to reuse the connection details you have already defined.

 

Application Name

Enter the application name required by Google Drive to get access to its APIs.

 

Access Token

Enter the access token required by Google Drive to access a Google Drive account and operate it. For how to get the access token, see Obtaining an access token for Google Drive.

 

Use HTTP Proxy

Select this check box if you are working behind an HTTP proxy.

 

Proxy Host

Enter the IP address of the HTTP proxy server.

This field is available only when the Use HTTP Proxy check box is selected.

 

Proxy Port

Enter the port number of the HTTP proxy server.

This field is available only when the Use HTTP Proxy check box is selected.

 

Use SSL

Select this check box if an SSL connection is used to access Google Drive.

 

Algorithm

Enter the name of the SSL cryptography algorithm.

This field is available only when the Use SSL check box is selected.

 

TrustStore File

Browse to or enter the path to the certificate TrustStore file that contains the list of certificates the client trusts.

This field is available only when the Use SSL check box is selected.

 

Password

Enter the password used to check the integrity of the TrustStore data.

This field is available only when the Use SSL check box is selected.

 

File Title

Enter the name for the file after being uploaded.

 

Destination Folder Name

Enter the name of the folder in which the file will be stored.

 

Replace if Existing

Select this check box to overwrite any existing file with the newly uploaded one.

 

Upload Incoming content as File

Select this option button if you upload data from an input flow of the preceding component.

 

Schema and Edit schema

A schema is a row description. It defines the number of fields to be processed and passed on to the next component.

The schema of this component is read-only. You can click the [...] button next to Edit schema to view the predefined schema with only one field named content which describes the data to be uploaded.

The Schema list and the Edit schema button appear only when the Upload Incoming content as File option button is selected.

 

Upload Local File

Select this option button when you upload data from a local file.

 

File

Browse to or enter the path to the file to be uploaded.

This field appears only when the Upload Local File option button is selected.

 

Expose As OutputStream

Select this option button to expose the output stream of this component, which can be used by other components to write the file content. For example, you can use the Use Output Stream feature of the tFileOutputDelimited component to feed a given tGoogleDrivePut's exposed output stream. For more information, see tFileOutputDelimited.

Advanced settings

tStatCatcher Statistics

Select this check box to gather the Job processing metadata at the Job level as well as at each component level.

Global Variables

ERROR_MESSAGE: the error message generated by the component when an error occurs. This is an After variable and it returns a string. This variable functions only if the Die on error check box is cleared, if the component has this check box.

A Flow variable functions during the execution of a component while an After variable functions after the execution of the component.

To fill up a field or expression with a variable, press Ctrl + Space to access the variable list and choose the variable to use from it.

For further information about variables, see Talend Studio User Guide.

Usage

This component can be used as a standalone component to upload a local file to Google Drive or an end component to upload data from an input flow of the preceding component to Google Drive.

Limitation

n/a

Managing files with Google Drive

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.

  6. Double-click the first tLogRow to open its Basic settings view in the Component tab.

  7. In the Mode area, select Table (print values in cells of a table) for a better display of the results.

Copying a file to the newly created folder

  1. Double-click tGoogleDriveCopy 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 File Name field, enter the name of the file to be copied. In this example, it is Talend Release Plan.csv.

  4. In the Destination Folder Name field, enter the name of the folder to which the file will be copied. In this example, it is Backup.

  5. Select the Rename (set new title) check box, and in the Destination Name field that appears enter a new name for the file after being copied to the destination folder. In this example, it is Talend Release Plan v1.0.csv.

  6. Click the [...] button next to Edit schema to view the predefined schema of tGoogleDriveCopy.

  7. Double-click the second tLogRow to open its Basic settings view in the Component tab.

  8. In the Mode area, select Table (print values in cells of a table) for a better display of the results.

Listing files and folders in Google Drive

  1. Double-click tGoogleDriveList 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 Folder Name field, enter the name of the folder to be iterated on. In this example, it is the root directory of Google Drive and you can use the alias root to refer to it.

  4. Select Both from the FileList Type drop-down list to list both files and folders in the root directory.

    Select the Includes subdirectories check box to iterate also on the subdirectories of the root directory.

  5. Double-click tIterateToFlow to open its Basic settings view in the Component tab.

  6. Click the [...] button next to Edit schema to open the schema editor.

    Click the [+] button to add four columns: ID, Title, and MimeType of the type string, and Size of the type long.

    Click OK to validate the changes and accept the propagation prompted by the pop-up dialog box.

  7. In the Mapping table, fill in the value for each column by selecting the corresponding cell in the Value column and then press Ctrl+Space and from the list of variables that appears select the corresponding global variable of the tGoogleDriveList component. In this example, select:

    • ((String)globalMap.get("tGoogleDriveList_1_ID")) for the ID column,

    • ((String)globalMap.get("tGoogleDriveList_1_TITLE")) for the Title column,

    • ((String)globalMap.get("tGoogleDriveList_1_MIME_TYPE")) for the MimeType column, and

    • ((Long)globalMap.get("tGoogleDriveList_1_SIZE")) for the Size column.

  8. Double-click the third tLogRow to open its Basic settings view in the Component tab.

  9. In the Mode area, select Table (print values in cells of a table) for a better display of the results.

Saving and executing the Job

  1. Press Ctrl + S to save the Job.

  2. Execute the Job by pressing F6 or clicking Run on the Run tab.

    As shown above, two files Talend Products.txt and Talend Release Plan.csv were uploaded to the folder Talend, then a new folder Backup was created in the folder Talend and the file Talend Release Plan.csv was copied to the new folder and renamed to Talend Release Plan v1.0.csv, and finally all files and folders are listed and displayed on the console.