jChat LogojChat Docs
Production Deployment

Media & File Storage

Configure local disk or cloud object storage (Cloudflare R2, AWS S3, Google Cloud Storage, MinIO) for media uploads.

Storage Architecture & Modes

In real-time chat applications, media attachments (images, videos, voice notes, PDF documents) and store uploads account for the majority of persistent data growth. JChat provides an integrated media storage pipeline with automatic WebP conversion, audio transcoding, and pluggable cloud or on-premise drivers configured via JCHAT_STORAGE_TYPE.

Storage Pipeline & Driver Topology
┌────────────────────────────────────────────────────────────────────────────────────────┐
│                             INCOMING MEDIA UPLOAD PIPELINE                             │
│                                                                                        │
│               Incoming Upload  ──▶    Media Pipeline    ──▶  Optimization             │
│               (Images / Audio)      Validation & Streaming   WebP & Audio Opus         │
└───────────────────────────────────────────┬────────────────────────────────────────────┘
                                            │
                                            ▼
┌────────────────────────────────────────────────────────────────────────────────────────┐
│                   STORAGE DRIVER ENGINE (JCHAT_STORAGE_TYPE)                           │
│                                                                                        │
│   ┌────────────────────────┐   ┌────────────────────────┐   ┌───────────────────────┐  │
│   │     CLOUDFLARE_R2      │   │         AWS_S3         │   │         LOCAL         │  │
│   │     Cloudflare R2      │   │     Amazon S3 Bucket   │   │   Local Server Disk   │  │
│   │  $0 Egress Bandwidth   │   │  IAM & Compliance S3   │   │     (/app/uploads)    │  │
│   └────────────────────────┘   └────────────────────────┘   └───────────────────────┘  │
│                                                                                        │
│   ┌────────────────────────┐   ┌────────────────────────┐                              │
│   │         MINIO          │   │          GCS           │                              │
│   │   Self-Hosted MinIO    │   │  Google Cloud Storage  │                              │
│   │  Air-Gapped & Private  │   │  Native Service Account│                              │
│   └────────────────────────┘   └────────────────────────┘                              │
└────────────────────────────────────────────────────────────────────────────────────────┘

Driver Comparison Matrix

Choose the storage driver that best fits your hosting budget, performance needs, and infrastructure topology:

Storage DriverIdentifierKey AdvantageEgress FeesRecommended For
Cloudflare R2CLOUDFLARE_R2S3-compatible, edge-cached, zero bandwidth fees$0 / GB (Free egress)High-volume production chat
Amazon S3AWS_S3Industry standard, fine-grained IAM & complianceAWS standard egressEnterprise AWS architectures
Local FilesystemLOCALZero setup required, stores directly on server diskNone (Server bandwidth)Dev, staging & small teams
MinIO S3MINIOSelf-hosted S3 API for private hardwareNone (Internal network)Air-gapped & on-premise VPS
Google CloudGCSNative Google Cloud Storage with service accountsGCP standard egressGoogle Cloud Platform stacks

Driver Configuration & Setup

Select your active storage provider below to inspect the required environment variables and step-by-step credentials guide:

Cloudflare R2 is the recommended production driver for JChat because it offers complete Amazon S3 API compatibility with $0 egress bandwidth fees, drastically reducing media hosting costs for active chat rooms.

Environment Configuration

Add the following variables to your production .env file:

JCHAT_STORAGE_TYPE="CLOUDFLARE_R2"
JCHAT_CLOUDFLARE_ACCOUNT_ID="your-cloudflare-account-id"
JCHAT_CLOUDFLARE_ACCESS_KEY_ID="your-r2-access-key-id"
JCHAT_CLOUDFLARE_SECRET_ACCESS_KEY="your-r2-secret-access-key"
JCHAT_CLOUDFLARE_BUCKET_NAME="jchat-uploads"
JCHAT_CLOUDFLARE_PUBLIC_URL="https://uploads.yourdomain.com"

Setup Steps

Create an R2 Bucket

Navigate to the Cloudflare Dashboard > R2 Object Storage > click Create bucket (e.g. jchat-uploads).

Generate API Credentials

Go to Manage R2 API Tokens > click Create API Token. Choose Object Read & Write permissions scoped to your bucket, then copy the generated Access Key ID and Secret Access Key.

Configure Public Custom Domain or R2.dev Subdomain

Under bucket Settings > Public Access, connect your custom CDN domain (e.g. https://uploads.yourdomain.com) or enable the managed r2.dev public access subdomain. Set this exact URL as JCHAT_CLOUDFLARE_PUBLIC_URL.

On this page