Skip to content

Google Drive — Upload

Type: googledrive-upload  ·  Package: Google Drive v1.0.5  ·  Output: Dictionary<string,object>

Uploads a file from the machine to Google Drive. You can choose its name in Drive and the destination folder, and you get back its ID and link to share or record it.

Reads the file at path and uploads it with a resumable upload, suited to large files. Without folderId, it lands in the root of My Drive (with a service account and no impersonateUser, in the service account’s own Drive). To upload into a specific folder, use its ID (from List files or Create folder).

  • The file is uploaded as is: an .xlsx stays an .xlsx, it is not converted to Google Sheets.
  • It always creates a new file: Drive allows duplicate names, so uploading the same file twice leaves two copies with different IDs. To avoid it, search first with List files (name = '…') and delete or rename the previous one.
ParameterTypeDefaultDescription
pathstring—Path of the local file to upload.
ParameterTypeDefaultDescription
sessionZoanGoogleDriveSession—Session from Google Drive — Connect. Inside Connect’s body it is inherited and you can leave it empty.
namestring—Name in Drive. If empty, the local file name.
folderIdstring—Destination folder ID. If empty, the root of My Drive; root sets it explicitly.

Returns a Dictionary with the metadata of the created file: uploaded["id"] (use it to share, move or download), uploaded["name"], uploaded["size"], uploaded["webViewLink"] (link to open it in the browser), uploaded["parents"]…

MessageCause and fix
'path' is required.path is empty or its expression returned null.
Local file not found.There is no file at path on the robot’s machine. Check it first with the file activities.
Upload failed: …The upload was interrupted (network, storage quota full, folder without write access). The text after the colon gives Google’s detail.
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 — Create folder name = "Reports" → output: folder
Google Drive — Upload path = "C:\reports\today.pdf" folderId = folder["id"] → output: uploaded
Google Drive — Share id = uploaded["id"] role = reader type = anyone