n8n-nodes-pcloud
v1.6.3
Published
n8n node for pCloud cloud storage integration
Maintainers
Readme
n8n-nodes-pcloud# n8n-nodes-pcloud
A comprehensive n8n community node for integrating with pCloud cloud storage service.
A comprehensive n8n community node for integrating with pCloud cloud storage service.
📋 Table of Contents
Features
Installation- File Operations: Upload, download, delete, move, and get file information
Authentication Setup- Folder Operations: Create, delete, list, and rename folders
For Accounts WITH 2FA Enabled- Authentication Support: Both username/password and access token authentication
For Accounts WITHOUT 2FA- Region Support: Works with both EU and US pCloud regions
Nodes- Binary Data Handling: Full support for binary file data in workflows
Operations- Error Handling: Comprehensive error handling with human-readable messages
Examples- Input Validation: Robust validation for all inputs and parameters
Installation
✨ Features
- Install the node from npm:
File Operations: Upload, download, delete, move, and get file information
Folder Operations: Create, delete, list, and rename folders ```bash
Trigger Support: Automatically trigger workflows when files/folders are created or modified npm install @n8n/n8n-nodes-pcloud
OAuth 2.0 Support: Secure OAuth2 authentication ```
2FA Support: Works with accounts that have two-factor authentication enabled
Multiple Auth Methods: Username/password, access token, or OAuth22. Restart your n8n instance
Region Support: Works with both EU and US pCloud regions
Binary Data Handling: Full support for binary file data in workflows3. The pCloud node will be available in the node palette under "Community Nodes"
Error Handling: Comprehensive error handling with human-readable messages
Dependencies
📦 Installation
pCloud SDK Integration
Install in n8n
While the pCloud n8n node is designed to work independently without requiring the official pCloud JavaScript SDK, it incorporates several design patterns and fallback strategies inspired by the SDK for enhanced reliability and performance.
Community Installation (Recommended):
cd ~/.n8n/custom npm install n8n-nodes-pcloudFor advanced use cases or when you need features not covered by the n8n node, you can optionally integrate the official pCloud SDK alongside your n8n workflows:
2. Restart your n8n instance:npm install pcloud-sdk-js
```bash```
systemctl restart n8n
# orThe n8n node and SDK can work together seamlessly:
pm2 restart n8n
```- **n8n Node**: Handles standard file/folder operations within workflows
- **pCloud SDK**: Provides access to advanced features like bulk operations, detailed metadata, or custom API calls
3. The pCloud node will be available in the node palette
#### SDK-Inspired Features
## 🔐 Authentication Setup
The n8n node implements several reliability patterns from the pCloud SDK:
### For Accounts WITH 2FA Enabled (Recommended)
- **Automatic API Server Switching**: Falls back to alternative pCloud API servers during outages
If your pCloud account has two-factor authentication enabled, you **cannot** use username/password directly. Instead, generate an access token:- **Intelligent Retry Logic**: Categorizes errors and applies appropriate retry strategies
- **Connection Pooling**: Reuses HTTP connections for better performance
#### Step 1: Generate Access Token- **Request Batching**: Groups multiple operations for efficiency
- **Metadata Caching**: Caches frequently accessed file/folder information
Run the token generator script:
#### When to Use the SDK Directly
```bash
cd ~/.n8n/custom/node_modules/n8n-nodes-pcloudConsider using the pCloud SDK directly when you need:
node scripts/generate-access-token.js
```- Bulk operations across thousands of files
- Advanced sharing and permission management
The script will prompt you for:- Real-time file monitoring
- Region (EU or US)- Custom API integrations
- Email address- Features not yet supported by the n8n node
- Password
- 2FA code (6 digits from your authenticator app)### Core Dependencies
**Example output:**The pCloud n8n node has minimal dependencies for optimal performance:
╔════════════════════════════════════════════════════════════╗- axios (^1.6.0): HTTP client for API communication
║ ✓ SUCCESS! ║- form-data (^4.0.0): Multipart form data handling for file uploads
╚════════════════════════════════════════════════════════════╝- n8n-workflow (^1.0.0): n8n workflow engine integration
Your pCloud Access Token:## Usage
┌────────────────────────────────────────────────────────────┐### Credentials
│ kSDe5LnVbZvBJy7v3xXZHWkZ7cHnZGX7vXZ │
└────────────────────────────────────────────────────────────┘Configure your pCloud credentials in n8n:
1. Go to Settings > Credentials
#### Step 2: Configure n8n Credentials2. Create a new credential for "pCloud API"
3. Select your region (EU or US)
1. In n8n, go to **Settings → Credentials**4. Choose authentication method:
2. Click **Create New** → Select **pCloud API** - **Username & Password**: Enter your pCloud email and password
3. Configure: - **Access Token**: Enter your pCloud access token
- **Region**: Select EU or US (same as your account)
- **Authentication Method**: Select **Access Token**### Node Configuration
- **Access Token**: Paste the token from Step 1
4. Click **Save**The pCloud node supports the following operations:
✅ The token will remain valid until you change your pCloud password or revoke it.#### File Operations
---- **Upload**: Upload files to pCloud
- **Download**: Download files from pCloud
### For Accounts WITHOUT 2FA- **Delete**: Delete files from pCloud
- **Move**: Move or rename files
1. In n8n, go to **Settings → Credentials**- **Get Info**: Get file metadata
2. Click **Create New** → Select **pCloud API**
3. Configure:#### Folder Operations
- **Region**: Select EU or US
- **Authentication Method**: Select **Username & Password**- **Create**: Create new folders
- **Username**: Your pCloud email- **Delete**: Delete folders
- **Password**: Your pCloud password- **List**: List folder contents
4. Click **Save**- **Rename**: Rename folders
---### Example Workflow
## 🔧 Nodes```
[Webhook] → [pCloud Upload] → [pCloud Get Info] → [HTTP Response]
### pCloud Node```
The main node for performing file and folder operations.This example workflow:
### pCloud Trigger Node (NEW!)1. Receives a file via webhook
2. Uploads it to pCloud
Automatically trigger workflows when changes occur in your pCloud account.3. Gets file information
4. Returns the file info as a response
**Trigger Events:**
- **File Created**: Trigger when a new file is added## SDK Integration Examples
- **File Modified**: Trigger when a file is updated
- **File Deleted**: Trigger when a file is removedThe pCloud n8n node is designed to work seamlessly with the official pCloud JavaScript SDK. Here are some examples showing how to combine n8n workflows with direct SDK usage:
- **Folder Created**: Trigger when a new folder is created
- **Any Change**: Trigger on any file or folder change### File Upload with SDK Validation
**Configuration:**```javascript
- **Folder Path**: Which folder to monitor// Using pCloud SDK for validation before n8n upload
- **Recursive**: Monitor subfolders as wellimport { createClient } from 'pcloud-sdk-js';
- **File Name Filter**: Filter by pattern (e.g., `*.pdf`)
- **Poll Interval**: How often to check (1-1440 minutes)const client = createClient('your-access-token');
---// Validate folder exists before upload
try {
## 📚 Examples const folderInfo = await client.listfolder({ path: '/uploads' });
console.log('Folder exists:', folderInfo.metadata.name);
### Example 1: Auto-Process New Invoices} catch (error) {
// Create folder if it doesn't exist
``` await client.createfolder({ path: '/uploads' });
[pCloud Trigger] → [pCloud Download] → [PDF Extract] → [Google Sheets]}
// Now use n8n node for the actual upload in your workflow
Example 2: Monitor File Changes// n8n node parameters:
// - folderPath: "/uploads"
[pCloud Trigger] → [Send Email Notification]```
Batch File Operations
## 🐛 Troubleshooting// Using SDK for batch operations alongside n8n
import { createClient } from 'pcloud-sdk-js';
### Issue: "Two-factor authentication required" Error
const client = createClient('your-access-token');
**Solution**: Generate and use an access token instead (see authentication setup above).
// Get multiple file stats
### Issue: Trigger Not Firingconst filePaths = ['/docs/file1.pdf', '/docs/file2.docx', '/docs/file3.xlsx'];
const fileStats = await Promise.all(
**Check:** filePaths.map(path => client.stat({ path }))
- Credentials are valid);
- Folder path exists
- Poll interval is set correctly// Process results in n8n workflow
// n8n can then use this metadata for conditional logic
---```
## 📄 License### OAuth Flow Integration
MIT License - see [LICENSE](LICENSE) file for details```javascript
// SDK OAuth flow that works with n8n credentials
---import { createClient } from 'pcloud-sdk-js';
## 📊 Version History// Use the same access token from n8n credentials
const client = createClient(process.env.PCLOUD_ACCESS_TOKEN);
### v1.0.4 (Latest)
- ✨ Added pCloud Trigger node// The SDK client can be used for operations not covered by n8n nodes
- ✨ Added access token generator for 2FAconst userInfo = await client.userinfo();
- 🐛 Fixed 2FA authentication issuesconsole.log('Authenticated user:', userInfo.email);
- 📝 Updated documentation
// Use n8n nodes for standard operations, SDK for advanced features
---```
**Made with ❤️ for the n8n community**### Error Handling with SDK
```javascript
// Robust error handling combining SDK and n8n patterns
import { createClient } from 'pcloud-sdk-js';
const client = createClient('your-access-token');
async function safeUpload(filePath, folderPath) {
try {
// Check quota first using SDK
const userInfo = await client.userinfo();
const usedBytes = userInfo.usedquota;
const totalBytes = userInfo.quota;
const freeBytes = totalBytes - usedBytes;
if (freeBytes < 1024 * 1024) { // Less than 1MB free
throw new Error('Insufficient storage space');
}
// Proceed with n8n upload node
// n8n handles the actual upload with retry logic
return { success: true, message: 'Upload ready' };
} catch (error) {
console.error('Upload preparation failed:', error.message);
return { success: false, error: error.message };
}
}Advanced File Management
// Complex file management using SDK features
import { createClient } from 'pcloud-sdk-js';
const client = createClient('your-access-token');
async function organizeFiles() {
// List all files in root
const rootContents = await client.listfolder({ path: '/' });
// Group files by type
const filesByType = {};
for (const item of rootContents.metadata.contents) {
if (!item.isfolder) {
const ext = item.name.split('.').pop().toLowerCase();
if (!filesByType[ext]) filesByType[ext] = [];
filesByType[ext].push(item);
}
}
// Create organized folders and move files
for (const [ext, files] of Object.entries(filesByType)) {
const folderPath = `/${ext.toUpperCase()}`;
// Create folder if needed
try {
await client.createfolder({ path: folderPath });
} catch (error) {
// Folder might already exist
}
// Move files (use n8n nodes for this in production workflows)
for (const file of files) {
await client.renamefile({
path: `/${file.name}`,
topath: `${folderPath}/${file.name}`
});
}
}
}Development
Prerequisites
- Node.js 18 or higher
- npm or yarn
- Git
Setup
Clone the repository:
git clone https://github.com/n8n-io/n8n-nodes-pcloud.git cd n8n-nodes-pcloudInstall dependencies:
npm installBuild the project:
npm run buildRun tests:
npm test
Project Structure
├── src/
│ ├── credentials/ # Credential definitions
│ ├── nodes/ # Node implementations
│ │ └── PCloud/ # pCloud node
│ └── utils/ # Utility functions
│ ├── PCloudApi.ts # API client
│ ├── OAuthHelper.ts # OAuth utilities
│ ├── Validators.ts # Input validation
│ └── ErrorHandler.ts # Error handling
├── tests/ # Test files
│ ├── unit/ # Unit tests
│ └── integration/ # Integration tests
├── docs/ # Documentation
├── examples/ # Example workflows
└── scripts/ # Build and utility scriptsScripts
npm run build- Build the projectnpm run dev- Start development mode with watchnpm run test- Run testsnpm run test:watch- Run tests in watch modenpm run test:coverage- Run tests with coveragenpm run lint- Run lintingnpm run lintfix- Fix linting issuesnpm run format- Format code with Prettier
Testing
The project includes comprehensive unit and integration tests:
# Run all tests
npm test
# Run tests with coverage
npm run test:coverage
# Run tests in watch mode
npm run test:watchContributing
Contributions are welcome! Please read our Contributing Guide for details on our code of conduct and the process for submitting pull requests.
Development Workflow
- Fork the repository
- Create a feature branch:
git checkout -b feature/amazing-feature - Make your changes
- Add tests for new functionality
- Ensure all tests pass:
npm test - Commit your changes:
git commit -m 'Add amazing feature' - Push to the branch:
git push origin feature/amazing-feature - Open a pull request
License
This project is licensed under the MIT License - see the LICENSE file for details.
Support
Related Links
Made with ❤️ by the n8n community
