Loopfour
Integrations

Google Drive actions

Reference for the Google Drive actions: the Google Drive connection, each action id, download, upload and sharing rules, outputs and an example.

The Google Drive block reads, writes, creates, organises and shares files and folders in Google Drive, including shared drives. For the plain-language guide, see Google Drive.

When to use it

Use it to read a document that a team keeps in Drive, to save a report or export into a folder, or to share a file with someone. There is no Google Drive trigger; for a sync, run on a schedule with getChangesStartPageToken and listChanges.

Connection

  • Provider id: google-drive. Google OAuth through Nango, scope https://www.googleapis.com/auth/drive.
  • The block sees only what the Google user behind the connection can see. Shared drive actions need a Google Workspace account.
  • Pin an account with config.connection. Without it, the step uses the company's default Google Drive connection.

Actions

Action idStudio labelWhat it does
google-drive.copyFileCopy FileCopy a file, optionally renamed and into another folder. Folders cannot be copied.
google-drive.createCommentCreate CommentAdd a comment to a file.
google-drive.createDriveCreate Shared DriveCreate a shared drive. Needs a Google Workspace account allowed to create shared drives.
google-drive.createFolderCreate FolderCreate a folder, in My Drive root unless a parent is set.
google-drive.deleteCommentDelete CommentDelete a comment from a file.
google-drive.deleteDriveDelete Shared DrivePermanently delete a shared drive. It must be empty unless a domain admin sets allowItemDeletion.
google-drive.deleteFileDelete FilePermanently delete a file or folder (and a folder’s contents), skipping the trash. To trash instead, use Update File with trashed.
google-drive.deletePermissionDelete PermissionRemove someone’s access to a file or folder.
google-drive.emptyTrashEmpty TrashPermanently delete every trashed file of the user, or of one shared drive.
google-drive.findFileFind FileFind files (not folders) whose name contains the given text, optionally of one MIME type.
google-drive.findFolderFind FolderFind folders whose name contains the given text.
google-drive.getAboutGet Drive InfoGet the connected user and their storage quota.
google-drive.getChangesStartPageTokenGet Changes Start TokenGet the token that marks now; pass it to List Changes later to get what changed since.
google-drive.getCommentGet CommentGet a comment on a file.
google-drive.getDriveGet Shared DriveGet a shared drive’s metadata.
google-drive.getFileGet FileGet a file or folder’s metadata.
google-drive.getPermissionGet PermissionGet one permission on a file or folder.
google-drive.getRevisionGet RevisionGet one revision’s metadata.
google-drive.hideDriveHide Shared DriveHide a shared drive from the default view.
google-drive.listChangesList ChangesList one page of changes since a page token. Keep calling with nextPageToken; the last page returns newStartPageToken for the next run.
google-drive.listCommentsList CommentsList one page of a file’s comments. Page with nextPageToken.
google-drive.listDrivesList Shared DrivesList one page of the shared drives the user can see. Page with nextPageToken.
google-drive.listFilesList FilesList one page of files and folders, e.g. the items in a folder. Page with nextPageToken.
google-drive.listPermissionsList PermissionsList who a file or folder is shared with. Page with nextPageToken.
google-drive.shareFileShare FileShare a file or folder by adding a permission for a user, group, domain, or anyone with the link. Google emails users and groups unless sendNotificationEmail is false.
google-drive.unhideDriveUnhide Shared DriveShow a hidden shared drive in the default view again.
google-drive.updateCommentUpdate CommentChange a comment’s text.
google-drive.updateDriveUpdate Shared DriveRename a shared drive or change its restrictions.
google-drive.updateFileUpdate FileRename a file or folder, change its description, star it, or move it to or from the trash.
google-drive.updatePermissionUpdate PermissionChange a permission’s role or expiry.
google-drive.uploadFileUpload FileCreate a file from text or base64 content (up to 5 MiB), optionally converted to a Google format.
google-drive.updateFileContentUpdate File ContentReplace a file’s content, keeping its ID, sharing and history.
google-drive.downloadFileDownload FileDownload a file as base64 (up to 3 MiB), or save it to workspace files with persistToFolder (up to 96 MiB). Google Docs, Sheets and Slides are exported.
google-drive.moveFileMove FileMove a file or folder into another folder.

Settings

FieldStudio labelTypeUsed byRequired for
connectionGoogle Drive Accountstring (connection id)AllOptional. Without it the step uses the company default connection for this system
fileIdFile IdstringcopyFile, createComment, deleteComment, deleteFile, deletePermission, getComment, getFile, getPermission, getRevision, listComments, listPermissions, shareFile, updateComment, updateFile, updatePermission, updateFileContent, downloadFile, moveFilecopyFile, createComment, deleteComment, deleteFile, deletePermission, getComment, getFile, getPermission, getRevision, listComments, listPermissions, shareFile, updateComment, updateFile, updatePermission, updateFileContent, downloadFile, moveFile
nameNamestringcopyFile, createDrive, createFolder, findFile, findFolder, updateDrive, updateFile, uploadFile, updateFileContentcreateDrive, createFolder, uploadFile
parentIdParent IdstringcopyFile, createFolder, uploadFile
contentContentstringcreateComment, updateComment, uploadFile, updateFileContentcreateComment, updateComment
requestIdRequest IdstringcreateDrive
descriptionDescriptionstringcreateFolder, updateFile, uploadFile
commentIdComment IdstringdeleteComment, getComment, updateCommentdeleteComment, getComment, updateComment
driveIdDrive IdstringdeleteDrive, emptyTrash, findFile, findFolder, getChangesStartPageToken, getDrive, hideDrive, listChanges, listFiles, unhideDrive, updateDrivedeleteDrive, getDrive, hideDrive, unhideDrive, updateDrive
allowItemDeletionAllow Item DeletionbooleandeleteDrive
useDomainAdminAccessUse Domain Admin AccessbooleandeleteDrive, getDrive, listDrives, updateDrive
permissionIdPermission IdstringdeletePermission, getPermission, updatePermissiondeletePermission, getPermission, updatePermission
mimeTypeMime TypestringfindFile
folderIdFolder IdstringfindFile, findFolder, listFiles, moveFilemoveFile
queryQuerystringfindFile, findFolder, listDrives, listFiles
includeTrashedInclude TrashedbooleanfindFile, findFolder, listFiles
orderByOrder BystringfindFile, findFolder, listFiles
pageSizePage SizenumberfindFile, findFolder, listChanges, listComments, listDrives, listFiles, listPermissions
pageTokenPage TokenstringfindFile, findFolder, listChanges, listComments, listDrives, listFiles, listPermissionslistChanges
includeDeletedInclude DeletedbooleangetComment, listComments
revisionIdRevision IdstringgetRevisiongetRevision
includeRemovedInclude RemovedbooleanlistChanges
startModifiedTimeStart Modified TimestringlistComments
typeTypestringshareFileshareFile
roleRolestringshareFile, updatePermissionshareFile
emailAddressEmail AddressstringshareFile
domainDomainstringshareFile
allowFileDiscoveryAllow File DiscoverybooleanshareFile
expirationTimeExpiration TimestringshareFile, updatePermission
sendNotificationEmailSend Notification EmailbooleanshareFile
emailMessageEmail MessagestringshareFile
transferOwnershipTransfer OwnershipbooleanshareFile, updatePermission
adminManagedRestrictionsAdmin Managed RestrictionsbooleanupdateDrive
copyRequiresWriterPermissionCopy Requires Writer PermissionbooleanupdateDrive
domainUsersOnlyDomain Users OnlybooleanupdateDrive
driveMembersOnlyDrive Members OnlybooleanupdateDrive
starredStarredbooleanupdateFile
trashedTrashedbooleanupdateFile
contentBase64Content Base64stringuploadFile, updateFileContent
contentTypeContent TypestringuploadFile, updateFileContent
convertToMimeTypeConvert To Mime TypestringuploadFile
exportMimeTypeExport Mime TypestringdownloadFile
persistToFolderPersist To FolderstringdownloadFile

The folder id root is the user's My Drive.

Find and list

  • listFiles, findFile and findFolder leave out trashed items unless includeTrashed is true, and include shared drives.
  • folderId keeps only items directly inside that folder. driveId searches one shared drive. query is a Drive search clause added with and.
  • findFile and findFolder match names that contain name.
  • Every list returns nextPageToken, which is null on the last page. Pass it as pageToken for the next page.

Download File

  • Without persistToFolder, the file must be 3 MiB or smaller. It comes back as base64 content with name, size and mimeType, plus text for text and JSON files (null otherwise).
  • With persistToFolder (a folder path in Files), the file can be up to 96 MiB. It is saved as <fileId>-<name> and the step returns workspaceFileId, filePath and persisted: true with no content. Pass workspaceFileId as fileId to the PDF block.
  • Google Docs, Sheets, Slides and Drawings are exported: as text/plain, text/csv, application/pdf and image/png by default. Set exportMimeType for another format, such as application/pdf for a Doc. Google limits exports to 10 MB. Other Google types, such as Forms, need exportMimeType.

Upload File and Update File Content

  • Set exactly one of content (text) or contentBase64. The content can be up to 5 MiB.
  • contentType defaults to text/plain for content and application/octet-stream for contentBase64.
  • uploadFile creates the file in My Drive unless parentId is set. Set convertToMimeType to application/vnd.google-apps.document or application/vnd.google-apps.spreadsheet to make a Google Doc or Sheet.
  • updateFileContent keeps the file's ID, sharing and history.

Sharing

  • shareFile needs type (user, group, domain or anyone) and role (reader, commenter, writer, fileOrganizer, organizer or owner). user and group need emailAddress; domain needs domain. owner needs transferOwnership: true.
  • Google emails the user or group unless sendNotificationEmail is false, so the step is marked as one that reaches people outside the workspace.

Delete and trash

  • deleteFile deletes permanently and skips the trash. To move an item to the trash, use updateFile with trashed: true.
  • emptyTrash permanently deletes everything in the user's trash, or in a shared drive's trash with driveId.
  • deleteDrive needs an empty shared drive unless a domain admin sets allowItemDeletion and useDomainAdminAccess.

Changes

Call getChangesStartPageToken once and save startPageToken. Each run, call listChanges with the saved token, follow nextPageToken until it is null, and save newStartPageToken for the next run.

Output

  • File and folder actions return the Drive file with id, name, mimeType, size, parents, driveId, description, starred, trashed, createdTime, modifiedTime and webViewLink.
  • List actions return files, comments, permissions, drives or changes, with nextPageToken.
  • Delete actions return the id and deleted: true; emptyTrash returns emptied: true.
  • The other actions return the Drive API object.

Read fields with {{steps.<stepId>.<path>}}, for example {{steps.find_report.files.0.id}}.

Example

Find the newest month-end report PDF in a folder, save it to Files, and share it with the controller without an email.

{
  "name": "Collect the month-end report",
  "trigger": { "type": "api" },
  "steps": [
    {
      "id": "find_report",
      "type": "action",
      "name": "Find the report",
      "action": "google-drive.findFile",
      "config": {
        "name": "Month-end report",
        "mimeType": "application/pdf",
        "folderId": "1AbCdEfGhIjKlMnOp",
        "orderBy": "modifiedTime desc",
        "pageSize": 1
      }
    },
    {
      "id": "save_report",
      "type": "action",
      "name": "Save the report to Files",
      "action": "google-drive.downloadFile",
      "config": {
        "fileId": "{{steps.find_report.files.0.id}}",
        "persistToFolder": "month-end"
      }
    },
    {
      "id": "share_report",
      "type": "action",
      "name": "Share with the controller",
      "action": "google-drive.shareFile",
      "config": {
        "fileId": "{{steps.find_report.files.0.id}}",
        "type": "user",
        "role": "reader",
        "emailAddress": "controller@example.com",
        "sendNotificationEmail": false
      }
    }
  ]
}

Live catalog

  • GET /api/v1/blocks/google-drive returns the actions and fields.
  • GET /api/v1/blocks/google-drive/actions/<operation>/examples returns stored examples where they exist.

Errors and limits

  • downloadFile waits up to 5 minutes for the file content.
  • A missing required field or a malformed ID fails the step before Google Drive is called. Google errors fail the step with Google's message.

On this page