@inteli.city/node-red-contrib-drive-collection
v1.0.1
Published
Node-RED nodes for Google Drive and OneDrive file operations
Downloads
45
Readme
node-red-contrib-drive-collection
Node-RED nodes for Google Drive and OneDrive file operations.
A single drive node performs all operations (upload, download, list, delete) against a provider chosen on the linked drive-config.
Nodes
| Node | Type | Purpose |
|---|---|---|
| drive-config | config | Provider selection + OAuth2 credentials |
| drive | operation | upload / download / list / delete |
drive-config
Shared credentials and provider selection.
| Field | Description |
|---|---|
| Provider | Google Drive or OneDrive |
| Tenant ID | Azure AD tenant (OneDrive only) |
| Client ID | OAuth2 client ID |
| Client Secret | Stored as a credential |
| Refresh Token | Paste manually from your OAuth flow |
The access token is refreshed automatically in memory and is never persisted.
drive
Unified node. Pick an operation in the editor (or override per-message via msg.operation).
Operations
| Operation | Required input | Output |
|---|---|---|
| upload | source per Input Source mode | msg.payload = metadata, msg.fileId = uploaded ID |
| download | fileId | per Output Target mode (see below) |
| list | none (defaults to root) | msg.payload = array of file metadata |
| delete | fileId (or path for OneDrive) | msg.payload = { deleted: true, fileId \| path } |
Upload — Input Source modes
| Mode | Behavior |
|---|---|
| payload (default) | Reads from msg.payload (Buffer or stream). msg.filePath is ignored. |
| file | Reads from the configured File Path (or msg.filePath). msg.payload is ignored. |
Download — Output Target modes
| Mode | Behavior |
|---|---|
| payload (default) | msg.payload is the readable stream returned by the provider. |
| file | Streams the response directly to the local filesystem. msg.payload becomes { filePath, fileId }; msg.filePath is also set. Set Overwrite to allow replacing existing files. |
File modes touch the local filesystem at runtime and may not work across environments (Docker, cloud). Ensure the Node-RED process can read/write the selected paths.
Inputs
All inputs may be set on the node and overridden via msg:
| Property | Description |
|---|---|
| msg.operation | overrides node operation (upload, download, list, delete) |
| msg.payload | upload body when Input Source is payload (Buffer or stream) |
| msg.filename | upload filename (default: timestamp) |
| msg.folderId | Google Drive folder ID |
| msg.path | OneDrive path, e.g. Documents/file.txt |
| msg.mimeType | upload MIME type (default: application/octet-stream) |
| msg.fileId | target file ID for download / delete |
| msg.filePath | local source path for upload when Input Source is file |
| msg.outputFilePath | local destination path for download when Output Target is file |
Provider constraints
- Google Drive does not support
path. UsefolderId. - OneDrive upload requires
path.
Errors
All errors are normalized to { code, message } and surfaced via node.error() and the status badge. Codes:
| Code | Meaning |
|---|---|
| INVALID_INPUT | Required input missing or empty |
| INVALID_OPERATION | Operation is not one of the four supported |
| UNSUPPORTED_INPUT | Input not supported for this provider (e.g. path on Google) |
| MISSING_CONFIG | drive-config not linked |
| PROVIDER_NOT_INITIALIZED | Config node failed to initialize the provider |
| NOT_FOUND | API returned 404 |
| UNAUTHORIZED | API returned 401 / token refresh failed |
| FORBIDDEN | API returned 403 |
| FILE_EXISTS | Local destination file exists and Overwrite is off |
| LOCAL_IO_ERROR | Local filesystem read/write failure |
| PROVIDER_ERROR | Other API failure |
Raw provider errors are not propagated.
Node status
| Color | Meaning |
|---|---|
| Yellow | In progress (shows operation name) |
| Green | Success (ok) |
| Red | Error (shows error code) |
OAuth2 Bootstrap
These nodes use OAuth2 with a refresh token. Obtain it externally:
- Google Drive — OAuth2 Playground with scope
https://www.googleapis.com/auth/drive - OneDrive — Azure app registration with scope
Files.ReadWrite
Paste the refresh token directly into the config node. The nodes do not implement a UI for the initial OAuth flow.
Design
- One unified node, one operation per message
- Config node as single source of truth for credentials
msg.*overrides always win over node config- Streams over buffering — download returns a stream, not a Buffer
- Provider-specific logic lives behind a uniform
{ upload, download, list, delete }interface - Errors are normalized to
{ code, message }— no raw provider errors leak - Manual OAuth bootstrap — no hidden auth flows
License
Apache-2.0
