๐Ÿ”ฌ Upload documents with validation, deduplication and Postgres storage

โšก 70 views ยท ๐Ÿ”ฌ Document Extraction & Analysis

Description

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
  3. File Validation The workflow checks:

    • File size against limits
    • MIME type against allowed formats

    Invalid files are rejected with a clear error response.

  4. Metadata Generation Generates:

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

  6. Conditional Processing

    • Duplicate found โ†’ returns existing document reference
    • New document โ†’ proceeds to storage
  7. Database Storage Stores document metadata in Postgres with a received status.

  8. 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


Requirements


Notes

๐Ÿ”— Nodes Used

Postgres, Webhook, n8n Form Trigger

๐Ÿ“ฅ Import

Download workflow.json and import into n8n: Workflow menu โ†’ Import from File

๐Ÿ“– Importing guide ยท ๐Ÿ”‘ Credential setup