Where ideas become reality

    Preparing your experience
    All projects
    Full-StackPrototype

    Discord File Storage — Chunk-Based File Storage Experiment

    A Node.js and Express file-storage experiment that uses Discord message attachments as chunk storage, MongoDB for metadata, and streamed downloads to reconstruct original files.

    December 24, 2025Full-Stack
    Discord File Storage — Chunk-Based File Storage Experiment project preview

    Built with

    Node.jsExpress.jsDiscord REST APIMongoDBMongooseEJSAxiosMulterbcryptjsexpress-session

    Project notes

    Behind the build

    Discord File Storage

    Overview

    Discord File Storage is a Node.js and Express-based file-storage experiment that uses a Discord server as the backing store for uploaded files.

    Instead of uploading an entire file as a single attachment, the application splits it into smaller chunks and uploads each chunk to Discord as a message attachment. MongoDB stores the file metadata and the Discord message and attachment identifiers required to retrieve the chunks later.

    During downloads, the application fetches the original Discord messages again to obtain their current CDN URLs, streams the chunks in the correct order, and reconstructs the original file.

    The application includes user authentication, automatically created private Discord channels, upload progress tracking, file management, and a responsive EJS-based interface.

    Key Features

    User Authentication

    • User registration and login using email and password.
    • Password hashing with bcrypt.
    • Session-based authentication.
    • MongoDB-backed session storage.
    • User-specific file management.

    Discord-Based Storage

    • Automatically creates a private Discord text channel for each registered user.
    • Uploads file chunks as Discord message attachments.
    • Stores Discord channel, message, and attachment identifiers in MongoDB.
    • Supports a configurable fallback upload channel.
    • Uses the Discord REST API for message and attachment operations.

    Chunked File Uploads

    • Splits uploaded files into fixed-size chunks on the server.
    • Default chunk size of 25 MB.
    • Configurable maximum file size, with a documented default of 10 GB.
    • Calculates SHA-256 hashes for individual chunks.
    • Tracks each chunk's upload status.
    • Stores chunk metadata for later reconstruction.

    Upload Progress Tracking

    • Tracks upload progress at the individual chunk level.
    • Exposes a status endpoint for frontend polling.
    • Reports uploaded chunk counts and overall progress.
    • Provides per-chunk status information.
    • Includes frontend upload status polling.

    File Download & Reconstruction

    • Re-fetches Discord messages when a file is downloaded.
    • Retrieves fresh attachment CDN URLs instead of relying on previously stored URLs.
    • Streams file chunks back in their original order.
    • Reconstructs the original file.
    • Preserves the original filename using the Content-Disposition response header.

    File Management

    • List uploaded files.
    • View individual file details.
    • Download stored files.
    • Delete files and their associated Discord messages.
    • Manage profile information and default Discord channel settings.

    Responsive User Interface

    • Server-rendered EJS templates.
    • Dark-themed interface.
    • Mobile-friendly responsive layout.
    • Drag-and-drop upload support.
    • Mobile navigation.
    • Upload progress updates.

    How It Works

    The application uses Discord messages as the storage layer and MongoDB as the metadata layer.

    1. User Registration

    When a user registers, the application creates a private Discord text channel for that user. The channel ID is stored with the user's account.

    2. Chunked Upload

    The uploaded file is streamed into fixed-size chunks. Each chunk is hashed using SHA-256 and uploaded to the user's Discord channel as a message attachment.

    MongoDB stores the associated chunk information, including:

    • Discord channel ID.
    • Discord message ID.
    • Discord attachment ID.
    • Chunk size.
    • SHA-256 hash.
    • Upload status.

    3. Upload Progress

    The frontend periodically requests the file status endpoint to retrieve overall upload progress and individual chunk statuses.

    4. Download & Reconstruction

    When a download is requested, the backend fetches each corresponding Discord message again to retrieve its current attachment CDN URL.

    The chunks are then streamed back in their original order to reconstruct the uploaded file.

    5. File Deletion

    When a file is deleted, the application removes its associated Discord messages and deletes the corresponding MongoDB metadata record.

    Technical Architecture

    LayerTechnologies
    RuntimeNode.js
    BackendExpress.js
    FrontendEJS, express-ejs-layouts
    DatabaseMongoDB, Mongoose
    Session Managementexpress-session, connect-mongo
    Authenticationbcryptjs
    Discord IntegrationDiscord REST API
    HTTP ClientAxios
    File UploadMulter, form-data
    File ProcessingStreaming, SHA-256
    SecurityHelmet, express-rate-limit, express-validator, CSRF protection
    DevelopmentNodemon, Prettier

    Security Implementation

    The project includes several security mechanisms for its authentication and upload workflows.

    • Passwords are hashed using bcrypt with 10 rounds.
    • Sessions use HttpOnly and SameSite=Lax cookies.
    • Sessions are persisted in MongoDB using connect-mongo.
    • State-changing routes validate double-submit CSRF tokens.
    • Authentication and upload endpoints use rate limiting.
    • Helmet configures HTTP security headers.
    • Input validation is handled through express-validator.

    Configuration & Installation

    Installation

    git clone https://github.com/RJRYT/discord-file-storage
    cd discord-file-storage
    npm install
    

    Copy example.env to .env and configure the required environment variables.

    Start the application

    # Production
    npm start
    
    # Development
    npm run dev
    

    The application runs locally at http://localhost:3000.

    Configuration

    Important environment variables include:

    VariablePurpose
    MONGO_URIMongoDB connection
    DISCORD_BOT_TOKENDiscord bot authentication
    DISCORD_GUILD_IDDiscord server used for channel creation
    DISCORD_UPLOAD_CHANNEL_IDOptional fallback upload channel
    CHUNK_SIZE_BYTESConfigurable chunk size
    MAX_FILE_SIZE_BYTESMaximum upload size
    SESSION_SECRETSession signing secret
    LOG_LEVELLogging verbosity

    Project Limitations

    This project is explicitly a learning and testing experiment, not a production-ready storage solution.

    • Discord is not designed to be a file-storage service.
    • Discord message attachments and CDN URLs are not guaranteed to remain available.
    • CDN URLs may change or be revoked.
    • Uploaded files do not have encryption at rest.
    • Files should be treated as public and temporary.
    • The application is not suitable for sensitive data or production storage workloads.

    The project demonstrates chunk processing, external API integration, metadata persistence, streaming downloads, and file reconstruction rather than providing a reliable cloud-storage replacement.

    Project Details

    • Project: Discord File Storage
    • Type: Learning / Test Project
    • Backend: Node.js and Express
    • Storage Mechanism: Discord Message Attachments
    • Metadata Database: MongoDB
    • License: ISC

    Links

    Keep exploring

    Related projects

    More work connected by shared tools, technologies, and ideas.

    Browse all projects