Google Drive — Upload
Google Drive — Upload
Section titled “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.
How it works
Section titled “How it works”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
.xlsxstays 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.
Required parameters
Section titled “Required parameters”| Parameter | Type | Default | Description |
|---|---|---|---|
path | string | — | Path of the local file to upload. |
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. |
name | string | — | Name in Drive. If empty, the local file name. |
folderId | string | — | Destination folder ID. If empty, the root of My Drive; root sets it explicitly. |
Output
Section titled “Output”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"]…
Common errors
Section titled “Common errors”| Message | Cause 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. |
Example
Section titled “Example”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 = anyoneRelated activities
Section titled “Related activities”- Google Drive — Download — download a file.
- Google Drive — Create folder — create the destination folder.
- Google Drive — Share — share the uploaded file.
- All Google Drive activities