The Google Drive action allows you to upload files to your Google Drive.
It supports various file types and can generate files dynamically using , including text files, PDFs, CSVs, and HTML files. Mechanic interacts with Google Drive via the Google Drive API, using OAuth2 for authentication.
Options
Option
Type
Description
account
string
Required: the Google account email address to authenticate with
uploads
hash
Required: a has specifying files to upload and their contents
Uploads hash structure
The uploads hash supports these properties:
Property
Type
Description
overwrite
boolean
Optional: when true, files with matching names will be overwritten. Defaults to false
[path/filename]
string | hash
Authentication
This action requires connecting a Google account with the appropriate Drive permissions. To connect an account:
Go to the Settings screen
Click Authentication
Follow the Google account connection flow
Folder Support
Files can be organized in folders by including path information in the filename:
Use forward slashes to separate folder names (e.g., "reports/2024/monthly/file.pdf")
Folders will be created automatically if they don't exist
Can only access folders created by this integration
Invalid characters not allowed: < > : " / \ | ? *
Path Examples
reports/monthly/report.pdf # Three levels deep
data/2024/q1/sales.csv # Four levels deep
archives/backups/files.zip # Three levels deep
The action returns details about the uploaded files. The response is an object with the following structure:
{
"uploads": {
[filepath: string]: {
"id": string, // Google Drive file ID
"name": string, // File name as stored in Drive
"mime_type": string, // MIME type of the uploaded file
"web_view_link": string, // URL to view the file in Google Drive
"path": string // Full folder path where file was created
}
}
}
One or more file paths mapped to their content. Paths can include folders (e.g., 'reports/monthly/file.txt'). Content can be either a direct string or a .