Skip to main content

Upload documents with validation, deduplication and Postgres storage

Workflow preview

Workflow preview
100%
Upload documents with validation, deduplication and Postgres storage preview
Open on n8n.io

1. Workflow 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, det...

Best for

  • Document Extraction automation workflows
  • advanced n8n builders looking for reusable templates

Tools used

n8n-nodes-base.formtrigger, n8n-nodes-base.webhook, n8n-nodes-base.set, n8n-nodes-base.if, n8n-nodes-base.code, n8n-nodes-base.postgres, n8n-nodes-base.stickynote

Source and attribution

This workflow is cataloged by N8N Workflows and links back to its original n8n.io source page by ResilNext.

Original n8n.io source

1.1 Workflow description

Title
Upload documents with validation, deduplication and Postgres storage
Workflow name
Upload documents with validation, deduplication and Postgres storage

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

  1. Document Upload Users upload files through a form or webhook endpoint.

  2. Configuration Defines:

  • Maximum file size
  • Allowed file types
  • Storage settings
  1. File Validation The workflow checks:
  • File size against limits
  • MIME type against allowed formats

Invalid files are rejected with a clear error response.

  1. Metadata Generation Generates:
  • Unique document ID (UUID)
  • File hash (SHA-256)
  • File name, size, and type
  • Upload timestamp and source
  1. Duplicate Detection Uses the file hash to check if the document already exists in the database.

  2. Conditional Processing

  • Duplicate found → returns existing document reference
  • New document → proceeds to storage
  1. Database Storage Stores document metadata in Postgres with a received status.

  2. Response Handling

  • Success → returns document ID
  • Duplicate → returns existing document ID
  • Error → returns validation details

Setup Instructions

  1. Configure form trigger or webhook endpoint
  2. Set max file size and allowed MIME types in config node
  3. Connect Postgres credentials
  4. Create a documents table with required fields
  5. Update configuration values as needed
  6. Test with sample document uploads
  7. 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.

1.2 Logical Blocks

This catalog entry is organized from the workflow JSON. The node-level section below shows the executable blocks available for review before importing the template.

2. Block-by-Block Analysis

Block 1 - Document Upload Form

Type / Role
n8n-nodes-base.formTrigger - formTrigger
Config choices
Version 2.3

Block 2 - Webhook Upload

Type / Role
n8n-nodes-base.webhook - webhook
Config choices
Version 2.1

Block 3 - Workflow Configuration

Type / Role
n8n-nodes-base.set - set
Config choices
Version 3.4

Block 4 - Check File Size

Type / Role
n8n-nodes-base.if - if
Config choices
Version 2.3

Block 5 - Check MIME Type

Type / Role
n8n-nodes-base.if - if
Config choices
Version 2.3

Block 6 - Generate Document Metadata

Type / Role
n8n-nodes-base.code - code
Config choices
Version 2

Block 7 - Check for Duplicate

Type / Role
n8n-nodes-base.postgres - postgres
Config choices
Version 2.6

Block 8 - Is Duplicate?

Type / Role
n8n-nodes-base.if - if
Config choices
Version 2.3

Block 9 - Insert Document Record

Type / Role
n8n-nodes-base.postgres - postgres
Config choices
Version 2.6

Block 10 - Return Success Response

Type / Role
n8n-nodes-base.set - set
Config choices
Version 3.4

Block 11 - Return Duplicate Response

Type / Role
n8n-nodes-base.set - set
Config choices
Version 3.4

Block 12 - Return Validation Error

Type / Role
n8n-nodes-base.set - set
Config choices
Version 3.4

Block 13 - Sticky Note1

Type / Role
n8n-nodes-base.stickyNote - stickyNote
Config choices
Version 1

Block 14 - Sticky Note

Type / Role
n8n-nodes-base.stickyNote - stickyNote
Config choices
Version 1

Block 15 - Sticky Note2

Type / Role
n8n-nodes-base.stickyNote - stickyNote
Config choices
Version 1

Block 16 - Sticky Note3

Type / Role
n8n-nodes-base.stickyNote - stickyNote
Config choices
Version 1

Block 17 - Sticky Note4

Type / Role
n8n-nodes-base.stickyNote - stickyNote
Config choices
Version 1

Block 18 - Sticky Note5

Type / Role
n8n-nodes-base.stickyNote - stickyNote
Config choices
Version 1

Block 19 - Sticky Note6

Type / Role
n8n-nodes-base.stickyNote - stickyNote
Config choices
Version 1

Block 20 - Sticky Note7

Type / Role
n8n-nodes-base.stickyNote - stickyNote
Config choices
Version 1

3. Summary Table

Workflow Upload documents with validation, deduplication and Postgres storage
Complexity advanced
Nodes 20
Categories Document Extraction
Author ResilNext
Published 23 Mar 2026

4. Reproducing the Workflow from Scratch

  1. 1. Download the workflow JSON

    Use the JSON export at /data/workflows/14274/14274.json as the source template for this automation.

  2. 2. Import the template into n8n

    Open n8n, import the downloaded JSON, and review each node before activating the workflow.

  3. 3. Configure credentials and variables

    Replace placeholder credentials, API keys, webhook URLs, account IDs, and environment-specific values with your own settings.

  4. 4. Test with sample data

    Run the workflow manually or in a staging workspace, inspect node output, and confirm downstream systems receive the expected data.

  5. 5. Activate and monitor

    Enable the workflow only after testing, then monitor executions, errors, and rate limits during the first production runs.

5. General Notes & Resources

Review imported nodes carefully before activation. This catalog entry is intended to help you inspect the workflow structure, understand required services, and find related templates faster.

Node names, credentials, schedules, webhook paths, and external service limits may need adjustment for your workspace.

Frequently asked questions

What does Upload documents with validation, deduplication and Postgres storage do?

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, det...

What do I need before importing this workflow?

Review the workflow JSON, configure any required credentials in n8n, and test the automation in a safe workspace before using it in production.

Can I customize this workflow?

Yes. Use the block-by-block analysis and the downloadable JSON to inspect each node, then adjust credentials, prompts, schedules, filters, or destinations for your Document Extraction use case.