Google Drive — Download
Google Drive — Download
Section titled “Google Drive — Download”Type: googledrive-download · Package: Google Drive v1.0.5 · Output: string
Downloads a file from Google Drive to the machine. Native Google documents are exported to an office format: Docs→docx, Sheets→xlsx, Slides→pptx, everything else (drawings, forms…)→pdf. That way the robot can open them afterwards with the Excel, Word or PDF activities.
How it works
Section titled “How it works”Looks up the name and type of the file id and saves it according to destination:
- If
destinationis an existing folder, the file is saved inside it with its Drive name; native Google documents get the extension of the exported format (Budget→Budget.xlsx). - Otherwise,
destinationis taken as the full file path: missing folders are created and that name is used as is (no extension is added here: include it yourself). - The download is written first to a temporary file in the same folder and only replaces the destination when it finishes complete: Google reported it finished and, for files that are not Google documents, the size matches Drive’s. If it is cut short or incomplete, the activity fails with a clear error, deletes the temporary file and leaves the destination as it was. Since version 1.0.5.
- An existing file with the same name is overwritten (only when the download finished complete).
- Pass only file IDs: a folder cannot be downloaded. When looping over a listing, filter with
eq(file["isFolder"], false).
Required parameters
Section titled “Required parameters”| Parameter | Type | Default | Description |
|---|---|---|---|
id | string | — | File ID. |
destination | string | — | Destination folder (the Drive name is used) or full file path. |
Optional parameters
Section titled “Optional parameters”| Parameter | Type | Default | Description |
|---|---|---|---|
session | ZoanGoogleDriveSession | — | Session from Google Drive — Connect. Inside Connect’s body it is inherited and you can leave it empty. |
Output
Section titled “Output”Returns a string with the full path of the saved file, including the extension added to Google documents. Use it in the next activity to open or process the file.
Common errors
Section titled “Common errors”| Message | Cause and fix |
|---|---|
'id' is required. | id is empty or its expression returned null. |
'destination' is required. | destination is empty or its expression returned null. |
The download of '…' did not finish: …. The destination file was not changed. | Google rejected or cut the transfer (for example, a native document over Google’s export limit, or a folder ID). Check the reason after the colon and try again; a Retry covers transient cuts. |
The download of '…' is incomplete: … of … bytes were received. The destination file was not changed. | The connection dropped before the whole file arrived. Try the download again. |
Access to the path '…' is denied. | The robot cannot write to that path, or the destination file is open in another program. |
No Google Drive session available. Provide 'session' from a googledrive-connect activity, or place this activity inside the Connect activity's body … | The activity is outside Connect’s body and received no session. Move it inside the body or pass the saved session. |
The service drive has thrown an exception. HttpStatusCode is … | Google rejected the call: unknown ID or no access, expired token or quota exceeded. See Google API errors. |
Example
Section titled “Example”Google Drive — Connect credential = credential("drive-operations") └─ body: Google Drive — List files query = "name contains 'invoice' and mimeType = 'application/pdf'" → output: found For Each items = found itemVariable = file └─ activities: Google Drive — Download id = file["id"] destination = "C:\downloads" → output: path Log message = "Saved to " + pathRelated activities
Section titled “Related activities”- Google Drive — Upload — upload a file.
- Google Drive — List files — find the file and its ID.
- Google Drive — Get info — see the file data.
- All Google Drive activities