Google Drive
The Google Drive connector reads, writes, lists and deletes files in a Google Drive folder. Mention it as @extfs_gdrive. Each run can take the next new file as a pipeline item.
Connect
The credential is an OAuth sign-in. In the credential dialog, enter a Credential Name, select Connect with Google, and sign in to Google in the pop-up window. Connectors, instances and credentials covers the rest of the setup.
| Setting | Default | What it does |
|---|---|---|
| Folder URL | Empty | The folder's full address, such as https://drive.google.com/drive/folders/1w_vc…. Left empty, the workflow works in My Drive. |
| Include sub-folders | Off | When on, a scan for new files also looks in the folders below the one the workflow scans. |
What a step can do
| Action | What it does |
|---|---|
claim_next_file | Claims the next available file for this run. claim_next_files claims several at once. |
get_file | Copies a file into the run's files. |
put_file | Uploads a file from the run's files. If a file with that name is already there, the step fails, unless the step says to replace it or to keep both. |
delete_file | Deletes a file. |
list_files | Lists files in a folder. It returns one file unless the step asks for more, and by default only files no run has taken yet; a step can ask for every file instead. A listing of new files reads at most 5,000 files and sub-folders from the folder, counting the files that don't match the step's pattern. When it stops there short of the number asked for, it says more may exist; claim_next_files takes them. |
mark_file_processed | Marks a claimed file Success or Failed. mark_files_processed marks several at once. |
Take the next new file from @extfs_gdrive under
Scans/. Convert it to PDF with @tiff_tools if it's a TIFF, then extract the text with @llm_whisperer.
How runs read the files
Unstract Flow reads the folder only while a run is going; nothing watches it between runs. When a run claims a file, Flow takes a file it has already found in that folder, and in its sub-folders when Include sub-folders is on, for this connector instance, matching the step's pattern if it has one. A new instance has no record of earlier runs, so it processes every file already in the folder again; so does an imported workflow, even one imported into the same organization. When none is left, it scans the folder for new files, at most once every 30 seconds for each folder and pattern, shared by runs working in parallel. The scan looks in that folder only, unless the connector's Include sub-folders setting is on. A file moved out of the folder after a scan found it is still read when a run claims it. A step after the claim marks the file Success or Failed. If a run ends with a file still in progress, the file is marked Failed once eight hours have passed since the claim; the check runs every 5 minutes. To free it sooner, select Release claims in the details of a run that ended Partial, Failed or Cancelled. Pipelines covers the states.
get_file copies a file into the run's files. When the step passes the claim's file_id, get_file reads that file by its Google Drive id and puts the copy at gdrive/<Drive id>/<path>, where <path> is the file's path inside the folder, such as gdrive/1Qx…/Scans/invoice.pdf. Two files with the same path then get separate copies. When the step passes no file_id, the copy goes at <path>. Later steps read the copy at the path get_file returns.
A listing returns up to 500 files. A file larger than 500 MB can't be copied into a run or uploaded, and a copy or an upload must finish within three minutes. Flow tells files apart by their content: a copy of a file Flow has already seen, under any name, isn't picked up again, and a file whose content changes counts as a new file.
- Google Docs, Sheets and Slides files can't be copied into a run. Export them to PDF or an Office format, and move the original out of the folder or claim with a pattern such as
*.pdf. - Give every file in the folder its own path. Google Drive lets two files in one folder have the same name, and a name can contain
/, soScans/a/b.pdfcan be a file nameda/b.pdfinScansand a fileb.pdfinScans/a. Aget_filestep without the claim'sfile_idfinds the file by its path and reads the same one of two such files every time. - Folders in shared drives aren't supported. Use a folder in My Drive, or one shared with you.