tGoogleDrivePut
tGoogleDrivePut Standard properties
These properties are used to configure tGoogleDrivePut running in the Standard Job framework.
The Standard
tGoogleDrivePut component belongs to the Cloud family.
The component in this framework is available in all Talend
products.
Basic settings
Property Type |
Select the way the connection details
This property is not available when other connection component is selected |
Connection Component |
Select the component that opens the database connection to be reused by this |
Application Name |
The application name required by Google Drive to get access to its |
OAuth Method |
Select an OAuth method used to
For more detailed information about how to access Google Drive using |
Access Token |
The access token generated through Google Developers OAuth 2.0 This property is available only when Access |
Client ID and Client Secret |
The client ID and client secret. These two properties are available only when Installed Application (Id & Secret) is selected from the OAuth Method drop-down list. |
Client Secret JSON |
The path to the client secret JSON file. This property is available only when Installed Application (JSON) is selected from the OAuth Method drop-down list. |
Service Account JSON |
The path to the service account JSON file. This property is available only when Service |
Use Proxy |
Select this check box when you are working behind a proxy. With this
|
Use SSL |
Select this check box if an SSL connection is used to access Google
|
File Name |
The name for the file after being uploaded. |
Destination Folder |
The name or ID of the folder in which uploaded data will be |
Access Method |
Select the method by which the destination folder is specified, either |
Replace if Existing |
Select this check box to overwrite any existing file with the |
Upload Mode |
Select one of the following upload modes from the drop-down list:
|
Schema and Edit schema |
A schema is a row description, and The schema of this component is read-only. You can click the
|
Advanced settings
DataStore Path |
The path to the Note: When your
client ID, client secret, or any other configuration related to the Installed Application authentication changes, you need to delete this credential file manually before running your Job again. This property is available |
tStatCatcher Statistics |
Select this check box to gather the Job processing metadata at the Job level |
Global Variables
ERROR_MESSAGE |
The error message generated by the component when an error occurs. This is an After |
PARENT_FOLDER_ID |
The ID of the parent folder. This is an After variable and it returns a string. |
FILE_ID |
The ID of the file. This is an After variable and it returns a string. |
Usage
Usage rule |
This component can be used as a standalone component to upload a local file to Google |
Managing files with Google Drive
This scenario describes a Job that uploads two files to an empty folder
Talend in the root directory of Google Drive, then creates a new
folder Talend Backup in the root directory and copies one of the two
files to the new folder Talend Backup, and finally lists and
displays all files and folders in the root directory of Google Drive on the console.
Creating a Job for managing files with Google Drive
-
Create a new Job and add a
tGoogleDriveConnection component, two
tGoogleDrivePut components, a
tFileInputRaw component, a
tGoogleDriveCreate component, a
tGoogleDriveCopy component, a
tGoogleDriveList component, and five
tLogRow components to the Job. -
Link the first tGoogleDrivePut component to the first
tLogRow component using a Row > Main connection. -
Do the same to link the tFileInputRaw component to the
second tGoogleDrivePut component, the second
tGoogleDrivePut component to the second
tLogRow component, the
tGoogleDriveCreate component to the third
tLogRow component, the
tGoogleDriveCopy component to the fourth
tLogRow component, the
tGoogleDriveList component to the fifth
tLogRow component. - Link the tGoogleDriveConnection component to the first tGoogleDrivePut component using a Trigger > On Subjob Ok connection.
-
Do the same to link the first tGoogleDrivePut component to the
tFileInputRaw component, the
tFileInputRaw component to the tGoogleDriveCreate component, the tGoogleDriveCreate component to the tGoogleDriveCopy component, and the tGoogleDriveCopy component to the tGoogleDriveList component.
Opening a connection to Google Drive
client secret JSON file.
-
The client secret JSON file has been downloaded into a local folder through Google
API Console. For more information, see How to access Google Drive using a client secret JSON file. -
An empty folder Talend has been created in the root
directory of Google Drive.
-
Double-click the tGoogleDriveConnection
component to open its Basic settings view in the
Component tab. -
In the Application Name field, enter the application name
required by Google Drive to get access to its API. In this example, it is
TalendProject. -
Select Installed Application (JSON) from the
OAuth Method drop-down list. -
In the Client Secret JSON field, specify the path to the
client secret JSON file you have generated,
D:/client_secret.json in this example.
Uploading files to Google Drive
-
Double-click the first tGoogleDrivePut
component to open its Basic settings view in
the Component tab. -
Select the component that will create the Google Drive connection from the
Connection Component drop-down list,
tGoogleDriveConnection_1 in this example. -
Select by Name from the Access Method
drop-down list and in the Destination Folder field, enter the
name of the folder in which the file will be uploaded, Talend
in this example.Note: When accessing a Google Drive resource by its name, if the name matches more
than one resource, an error will be thrown because the resource cannot be
identified precisely. In this case, you can specify the Google Drive resource
using a pseudo path hierarchy, like /Talend/Documentation.
This example specifies a folder named Documentation under
the folder Talend under the Google Drive
root folder. -
In the File Name field, enter the name for the file after
being uploaded. In this example, it is Talend
Customers.csv. -
Select Upload Local File from the Upload Mode drop-down list and in the File field, browse to or enter the path to the file to
be uploaded. In this example, it is D:/Downloads/Talend
Customers.csv. -
Double-click the tFileInputRaw component and on its
Basic settings view, select Read the file as a
bytes array in the Mode area and specify the
path to the file whose content will be uploaded in the
Filename field, D:/Downloads/Talend
Products.txt in this example. -
Double-click the second tGoogleDrivePut component to open
its Basic settings view in the Component tab. - Repeat step 2 to step 3 to configure this component.
-
In the File Name field, enter the name for the file after
being uploaded. In this example, it is Talend
Products.txt. -
Select Upload Incoming content as File from the
Upload Mode drop-down list.
Creating a new folder in Google Drive
-
Double-click tGoogleDriveCreate to open its Basic
settings view in the Component
tab. -
Select the component that will create the Google Drive connection from the
Connection Component drop-down list, tGoogleDriveConnection_1
in this example. -
In the Parent Folder field,
enter the name of the folder in which a new folder will be created. In this example,
it is root. -
In the New Folder Name
field, enter the name of the folder to be created. In this example, it is
Talend Backup. -
Double-click the third tLogRow component to open its Basic
settings view in the Component
tab. -
In the Mode area, select
Vertical (each row is a key/value list) for a better
display of the results.
Copying a file to the newly created folder
-
Double-click the tGoogleDriveCopy component to open its Basic settings view in the Component tab.
-
Select the component that will create the Google Drive connection from the
Connection Component drop-down list, tGoogleDriveConnection_1
in this example. -
Select File from the Copy Mode
drop-down list. -
In the Source field, enter
the name of the file to be copied. In this example, it is Talend
Customers.csv. -
In the Destination Folder
Name field, enter the name of the folder to which the file will be
copied. In this example, it is Talend Backup. -
Select the Rename (set new
title) check box and in the Destination
Name field, enter a new name for the file after being copied to the
destination folder. In this example, it is Talend Customers
v1.0.csv. -
Double-click the fourth tLogRow component to open its Basic
settings view in the Component
tab. -
In the Mode area, select
Vertical (each row is a key/value list) for a better
display of the results.
Listing files and folders in Google Drive
-
Double-click the tGoogleDriveList component to open its Basic settings view in the Component tab.
-
Select the component that will create the Google Drive connection from the
Connection Component drop-down list, tGoogleDriveConnection_1
in this example. -
In the Folder Name field,
enter the name of the folder in which the files/folders will be listed. In this
example, it is the root directory of Google Drive and you can use the alias
root to refer to it. -
Select Both from the
FileList Type drop-down list to list both
files and folders in the root directory. -
Select the Include SubDirectories check box
to list also the files/folders in the subdirectories. -
Double-click the fifth tLogRow component to open its Basic
settings view in the Component
tab. -
In the Mode area, select
Vertical (each row is a key/value list) for a better
display of the results.
Saving and executing the Job
-
Press Ctrl + S to save the
Job. -
Execute the Job by pressing F6 or clicking Run on the
Run tab.As shown above, two files Talend Products.txt and
Talend Customers.csv were uploaded to the folder
Talend, then a new folder Talend
Backup was created in the root folder and the file
Talend Customers.csv was copied to the new folder and
renamed to Talend Customers v1.0.csv, and finally all files
and folders in the root directory are listed on the console.