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.
Driver Comparison Matrix
Choose the storage driver that best fits your hosting budget, performance needs, and infrastructure topology:
| Storage Driver | Identifier | Key Advantage | Egress Fees | Recommended For |
|---|---|---|---|---|
| Cloudflare R2 | CLOUDFLARE_R2 | S3-compatible, edge-cached, zero bandwidth fees | $0 / GB (Free egress) | High-volume production chat |
| Amazon S3 | AWS_S3 | Industry standard, fine-grained IAM & compliance | AWS standard egress | Enterprise AWS architectures |
| Local Filesystem | LOCAL | Zero setup required, stores directly on server disk | None (Server bandwidth) | Dev, staging & small teams |
| MinIO S3 | MINIO | Self-hosted S3 API for private hardware | None (Internal network) | Air-gapped & on-premise VPS |
| Google Cloud | GCS | Native Google Cloud Storage with service accounts | GCP standard egress | Google 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.