n8n File Handling: Upload, Download, and Organize Automatically
π Introduction
n8n is a powerful workflow automation tool that lets you build logic for file processing β whether youβre uploading, downloading, renaming, or organizing files in cloud services or local storage. This guide will show you how to handle files efficiently and automatically with real-world examples.
β Common Use Cases
- Automatically download invoices from email attachments and upload to Google Drive.
- Rename and organize files based on file type or metadata (e.g., dates, tags).
- Auto-upload generated PDF reports to Dropbox or an FTP server.
- Handle media files from Telegram or webhooks and sort them into folders.
π§° Prerequisites
Before you start:
- Self-hosted or cloud-hosted n8n instance
- Basic knowledge of nodes and workflows
- Credentials set up for cloud storage services (e.g., Google Drive, Dropbox, S3)
π οΈ File Download Automation
Example: Download Email Attachment to Local
Input: Email with PDF invoice
Workflow:
IMAP Email
Node β Triggers on new email with attachmentMove Binary Data
Node β Extracts fileWrite Binary File
Node β Saves it to a folder (/data/invoices/
)
# Output file
/data/invoices/invoice-{{date}}.pdf
βοΈ File Upload Automation
Example: Upload to Google Drive
Input: File generated from another node or uploaded via webhook
Workflow:
Webhook
Node β Accepts file inputSet Filename
β Rename based on timestamp or contextGoogle Drive
Node β Uploads file to correct folder
π Tip: Use expressions like {{$now.toFormat("yyyy-LL-dd")}}
in filenames.
π Organize Files Automatically
Sort Files by Date or Type
Workflow:
Webhook
orRead Folder
Node β Reads a file or batchSwitch
Node β Routes based on file extensionMove Binary Data
β Changes file name/pathWrite Binary File
β Saves in organized folders
/data/reports/2025-07/invoice-1.pdf
/data/images/july/photo-23.jpg
π Rename Files Dynamically
Use the Set
or Function
node to create logic-based filenames:
return {
binary: {
data: {
fileName: `invoice-${new Date().toISOString().split('T')[0]}.pdf`,
}
}
}
π¦ Bonus: Compress or Archive Files
Use the Execute Command
or n8n-nodes-base.zip
custom nodes (if available) to compress files before uploading or archiving them.
π§ Best Practices
- Store files in volume-mapped directories for Docker setups
- Use a consistent folder structure (
/data/{type}/{year}-{month}/
) - Automatically delete old files using a scheduled workflow
- Sanitize filenames to avoid path errors or overwriting
π Real-World Applications
- Client document management
- Digital asset pipelines (e.g., media uploads)
- Secure data archival for compliance
- Invoice processing & accounting automation
π€ Need Help with File Automation?
I offer expert setup services for:
- Google Drive, Dropbox, and FTP integrations
- Building secure file workflows
- Automating document management across platforms
π Get in touch to simplify your file handling with n8n.