Google Drive — Copy
Google Drive — Copy
Section titled “Google Drive — Copy”Type: googledrive-copy · Package: Google Drive v1.0.5 · Output: Dictionary<string,object>
Creates a copy of a file in Google Drive. You can choose the copy’s name and the folder it goes to: ideal to produce a new document from a template without touching the original.
How it works
Section titled “How it works”Google duplicates the file id on the server (it does not go through the robot’s machine, so it is fast even for large files). By default the copy is called “Copy of …” and stays in the same folder as the original; set name and folderId to change that. Native Google documents are copied as Google documents.
It only copies files: with a folder ID, Google rejects the operation.
Required parameters
Section titled “Required parameters”| Parameter | Type | Default | Description |
|---|---|---|---|
id | string | — | ID of the file to copy. |
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 of the copy. If empty, “Copy of …” with the original name. |
folderId | string | — | Destination folder ID. If empty, the original’s folder. |
Output
Section titled “Output”Returns a Dictionary with the copy’s metadata: copy["id"] is the new ID, different from the original.
Common errors
Section titled “Common errors”| Message | Cause and fix |
|---|---|
'id' is required. | id is empty or its expression returned null. |
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”Produce the monthly report from a Google Sheets template:
Google Drive — Connect credential = credential("drive-operations") └─ body: Google Drive — Copy id = templateId name = "Report " + now().ToString("yyyy-MM") folderId = reportsId → output: copyGoogle Sheets — Open credential = credential("drive-operations") spreadsheetId = copy["id"] └─ body: Google Sheets — Write sheet sheet = "Data" values = dataRelated activities
Section titled “Related activities”- Google Drive — Move — move instead of copy.
- Google Drive — Rename — rename a file.
- Google Drive — Create folder — create the destination folder.
- All Google Drive activities