n8n-nodes-yuppie-google-drive
v2.6.0
Published
n8n community node for Google Drive operations - upload, download, list, create folder, and search
Maintainers
Readme
n8n-nodes-yuppie-google-drive
这是一个 N8N 社区节点,允许你上传文件到 Google Drive 指定文件夹。
n8n 是一个工作流自动化平台。
功能特性
- 上传文件到 Google Drive 指定文件夹
- 支持 OAuth2 和 Service Account 两种认证方式
- 支持自定义文件名
- 支持简化输出或完整 API 响应
- 自动处理二进制文件数据
安装
社区节点安装(推荐)
- 在 n8n 中进入 设置 > 社区节点
- 选择 安装社区节点
- 输入
n8n-nodes-yuppie-google-drive - 点击 安装
手动安装
npm install n8n-nodes-yuppie-google-drive使用方法
1. 配置凭证
节点支持两种 Google Drive API 认证方式:
OAuth2(推荐)
- 在 n8n 中创建新的 Google Drive OAuth2 API 凭证
- 按照 Google OAuth2 流程授权
Service Account
- 在 n8n 中创建新的 Google API 凭证
- 上传 Service Account JSON 密钥文件
- 确保服务账户有访问目标 Drive 的权限
2. 配置节点参数
| 参数 | 说明 | 必填 | |------|------|------| | Authentication | 认证方式(OAuth2 或 Service Account) | 是 | | Input Data Field Name | 包含二进制文件数据的输入字段名称 | 是 | | File Name | 上传后的文件名(留空使用原始文件名) | 否 | | Folder ID | 目标文件夹 ID(使用 "root" 表示根目录) | 是 | | Simplify Output | 是否返回简化的响应 | 否 |
3. 获取文件夹 ID
有以下几种方式获取 Google Drive 文件夹 ID:
- 从 URL 获取:打开文件夹,URL 中
https://drive.google.com/drive/folders/{FOLDER_ID}的部分 - 使用 n8n 的 Google Drive 节点:列出文件夹获取 ID
- 使用 "root":直接上传到根目录
4. 输入数据格式
节点期望从上一个节点接收包含二进制数据的数据项。例如:
{
"json": {},
"binary": {
"data": {
"data": "base64_encoded_content",
"mimeType": "image/png",
"fileName": "screenshot.png"
}
}
}5. 输出数据格式
简化输出示例:
{
"id": "1a2b3c4d5e6f7g8h9i",
"name": "MyFile.pdf",
"webViewLink": "https://drive.google.com/file/d/...",
"webContentLink": "https://drive.google.com/uc?id=..."
}完整输出包含 Google Drive API 返回的所有字段。
示例工作流
从 HTTP 下载并上传到 Google Drive
HTTP Request 节点:下载文件
- 设置响应格式为 File
Yuppie Google Drive Upload 节点:上传文件
- Input Data Field Name:
data - File Name:
downloaded-file.pdf(可选) - Folder ID:
your-folder-id或root
- Input Data Field Name:
开发
# 安装依赖
npm install
# 验证节点配置
npm run validate
# 构建
npm run build
# 开发模式(监听文件变化)
npm run dev
# 格式化代码
npm run format
# 检查代码
npm run lint测试
详细的测试指南请查看 TESTING.md。
快速测试步骤:
验证节点配置:
npm run validate构建节点:
npm run build在 n8n 中测试:
- 方式一:本地开发模式
npm link cd /path/to/n8n npm link n8n-nodes-yuppie-google-drive pnpm start - 方式二:导入示例工作流
- 将
workflow-example.json导入到 n8n - 配置 Google Drive 凭证
- 运行工作流
- 将
- 方式一:本地开发模式
技术架构
- 基于 n8n-workflow 构建
- 使用 Google Drive API v3
- 支持 multipart 文件上传
- TypeScript 实现
许可证
MIT
