Upload documents with validation, deduplication and Postgres storage
Workflow preview
$20/month : Unlimited workflows
2500 executions/month
THE #1 IN WEB SCRAPING
Scrape any website without limits
HOSTINGER
Early Deal
DISCOUNT 20% Try free
DISCOUNT 20%
Self-hosted n8n
Unlimited workflows - from $4.99/mo
#1 hub for scraping, AI & automation
6000+ actors - $5 credits/mo
Overview
Overview
This workflow provides a reliable and secure system for uploading and managing documents.
It accepts files via form or webhook, validates file size and type, generates unique metadata, detects duplicates using file hashing, and stores records in Postgres. It ensures clean, consistent, and duplicate-free document intake.
How It Works
Document Upload Users upload files through a form or webhook endpoint.
Configuration Defines:
- Maximum file size
- Allowed file types
- Storage settings
- File Validation The workflow checks:
- File size against limits
- MIME type against allowed formats
Invalid files are rejected with a clear error response.
- Metadata Generation Generates:
- Unique document ID (UUID)
- File hash (SHA-256)
- File name, size, and type
- Upload timestamp and source
Duplicate Detection Uses the file hash to check if the document already exists in the database.
Conditional Processing
- Duplicate found → returns existing document reference
- New document → proceeds to storage
Database Storage Stores document metadata in Postgres with a
receivedstatus.Response Handling
- Success → returns document ID
- Duplicate → returns existing document ID
- Error → returns validation details
Setup Instructions
- Configure form trigger or webhook endpoint
- Set max file size and allowed MIME types in config node
- Connect Postgres credentials
- Create a
documentstable with required fields - Update configuration values as needed
- Test with sample document uploads
- Activate the workflow
Use Cases
- Secure document upload systems
- Preventing duplicate file storage
- Building document intake APIs
- Managing tax or financial documents
- Creating audit-ready upload pipelines
Requirements
- n8n instance with form/webhook support
- Postgres database
- File upload handling enabled
Notes
- SHA-256 hashing ensures accurate duplicate detection.
- You can extend storage to cloud services like S3 or Google Cloud Storage.
- Add authentication to webhook endpoints for production use.
- Customize validation rules based on your business requirements.