Links

Google Drive

Learn how to connect to Google Drive with Digibee iPaaS and use the List, Download, Upload and Delete file operations.
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:
  • Account: sets the account to be used by the component.
  • Operation: sets the operation to be executed (List, Download, Upload, Delete).
  • 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 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.
  • File Extension 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: this parameter is available for the Upload operation and defines the name of the remote file of which the upload will be made.
  • Query: this parameter is available for the List operation and defines the query language of filters during the operation. For more information about this language, visit the official Google documentation.
  • Page Size: this parameter is available for the List operation and refers to the amount of objects returned in the search.
  • Page Token: this parameter is available for the List operation. If there're more results after the list, the parameter will be informed so that the paginated listing can continue.
  • File ID: this parameter is available for the Delete and Download operations and informs 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
}
Last modified 2mo ago