Google Drive connects to your Google Drive drive and perform list, download, upload and delete file operations.

Take a look at the configuration parameters of the component:

  • File Name: name of the file locally saved in the pipeline. For the upload operation, the name of the file is already saved; in the download operation, this parameter defines the name and how the file will be saved.

  • Folder ID: Google folder ID. It's connected in the superior part of the URL when it's inside the folder selected in your Google Drive.

  • File Type: extension type of the file to make upload. Eg.: text/csv, text/xml, image/png. If it's not specified, the upload will be made with the application/octet-stream type.

  • Mime Type On Upload: if you want to convert the file into a Google Workspace file type, such as a Google Doc or Sheet, set the mime type and the component will do the conversion while uploading. The file converted to a Google Workspace type is not downloadable.

  • Remote File Name: used for the upload operation only. This parameter defines the name of the remote file of which the upload will be made.

  • Operation: list, download, upload, delete.

  • Query: used in the list operation. This parameter defines the query language of filters during the list operation. To know more about this language, click here

  • Page Size: used in the list operation, it refers to the amount of objects returned in the search.

  • Page Token: used in the list operation. If there're more results after the list, this parameter will be informed so that the paginated listing can continue.

  • File ID: used in the delete and download operations, this is the file ID.

  • Fail On Error: if the option is enabled, the execution of the pipeline with error will be interrupted; otherwise, the pipeline execution proceeds, but the result will show a false value for the “success” property.


Google Drive doesn't follow the same folders hierarchy. Therefore, it's not possible to make searches and specify a directory path.

Example: dir1/dir2/dir3/fileName.extension


Another detail about Google Drive is that you can save files with the same name in the same directory. That's why the API defined by Google uses the fileId to download or delete files instead of the file itself.

IMPORTANT: to perform any of these operations, it's necessary to register a OAuth 2 ACCOUNT with "https://www.googleapis.com/auth/drive" scope


             

Messages flow

LIST

  • Input

{

              "query": "'11HMcyPhqH4OpAVv7p0Ip1uNu-vGk0nKV' in parents",

              "pageSize": 5,

              "pageToken": null,

              "operation": "list",

              "failOnError":false

         

}

           

  • Output

[{

"name": "REMOTE_FILE_NAME or REMOTE_FOLDER_NAME",

isFolder: false,

"fileId": "FILE_ID",

"mimeType": "FOLDER OR FILE MIME_TYPE",

"description": "FOLDER or FILE DESCRIPTION"

}]

            

GOOGLE QUERY LANGUAGE

See some query examples:
       

  • To search all the files/folder inside a specific folder:

"query": " 'FOLDER_ID' in parents "

        

  • To search files that have the same specific name inside a folder:

"query": " 'FOLDER_ID' in parents and name = 'FILE NAME' "

          

  • To search a specific name inside all your Drive:

"query": " name = 'FILE NAME' "

        

IMPORTANT: in the query above, the search will be made in your Drive, including the Trash folder. If you don't want to search anything in the Trash folder, then use the following query:

"query": " name = 'FILE NAME' and trashed = false "

        

  • To search a specific file in 2 directories:

"query": "'FOLDER_ID_1' in parents or 'FOLDER_ID_2' in parents and name = 'FILE NAME'"

          

Output

{

              "data": [{

"name": "REMOTE_FILE_NAME or REMOTE_FOLDER_NAME",

isFolder: false,

"fileId": "FILE_ID",

"mimeType": "FOLDER OR FILE MIME_TYPE",

"description": "FOLDER or FILE DESCRIPTION"

}],

              "pageToken": "PAGE_TOKEN",

              "success":true

  }

        

UPLOAD

  • Input

             "folderId": "11HMcyPhqH4OpAVv7p0Ip1uNu-vGk0nKV",

              "fileType": "text/csv",

              "remoteFileName": "test",

              "operation": "upload",

              "fileName": "test",

              "failOnError":false

  }

 

  • Output

{

              "folderId": "11HMcyPhqH4OpAVv7p0Ip1uNu-vGk0nKV",

  "fileId": "FILE_ID_UPLOADED",

              "remoteFileName": "test",

              "fileName": "test",

              "success":true

  }

          

DOWNLOAD

  • Input

{

              "fileId": "FILE_ID",

              "operation": "download",

              "fileName": "test",

              "failOnError":false

  }

         

  • Output

{

              "fileId": "FILE_ID_UPLOADED",

              "fileName": "test",

              "success":true

  }

      

DELETE

  • Input

{

              "fileId": "FILE_ID",

              "operation": "delete",

              "failOnError":false

  }

         

  • Output

{

              "fileId": "FILE_ID_UPLOADED",

              "success":true

  }
Did this answer your question?