Skip to content

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.

Looks up the name and type of the file id and saves it according to destination:

  • If destination is 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, destination is 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).
ParameterTypeDefaultDescription
idstring—File ID.
destinationstring—Destination folder (the Drive name is used) or full file path.
ParameterTypeDefaultDescription
sessionZoanGoogleDriveSession—Session from Google Drive — Connect. Inside Connect’s body it is inherited and you can leave it empty.

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.

MessageCause 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.
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 " + path