Custom S3 (Optional)
EdgeChat uses native Cloudflare R2 by default. R2 users do not need any new configuration or deployment steps. Follow Attachments and Storage as before.
Use this guide only for another S3-compatible service. Since 2.21.0, custom S3 needs just one additional Secret, without editing Actions or deployment templates.
Already storing attachments?
Switching does not move files or read/write both backends. Read Migration and Returning to R2 before switching an existing site.
GitHub Actions: Add One Secret
Prepare an existing private bucket with your S3 provider and obtain its endpoint, bucket name, Access Key ID, and Secret Access Key.
In your EdgeChat project fork on GitHub, open Settings → Secrets and variables → Actions → Secrets → New repository secret.
Name it
EDGECHAT_S3and paste this JSON, replacing the four values:json{ "endpoint": "https://s3.example.com", "bucket": "edgechat", "accessKeyId": "YOUR_ACCESS_KEY", "secretAccessKey": "YOUR_SECRET_KEY" }Open Actions → 00 Deploy Worker → Run workflow and complete deployment.
Sign in and test file uploads, downloads, and avatar changes. Run the admin installation check to confirm storage is available.
No R2 activation, public bucket, or browser CORS configuration is needed. Actions skips native R2 provisioning and injects the configuration through a Wrangler Secret without deleting existing buckets. Other Cloudflare deployment credentials still follow the Actions guide.
Four Required Fields
| Field | Value |
|---|---|
endpoint | The provider's HTTPS S3 API URL, not its dashboard or public download URL. Exclude the bucket name, embedded credentials, and query parameters. Gateway path prefixes are supported. |
bucket | An existing bucket name; EdgeChat does not create external buckets |
accessKeyId | Access key ID |
secretAccessKey | Corresponding secret key |
The service must support AWS SigV4 and ListObjectsV2. Credentials only need the equivalent of GetObject, PutObject, DeleteObject, and ListBucket on the selected bucket. Never put real credentials in source, TOML, Repository Variables, or public issues.
Only When Your Provider Requires It
| Optional field | Default | When to change it |
|---|---|---|
region | us-east-1 | Use the provider's required region, or auto for the R2 S3 API |
forcePathStyle | true | Use the boolean false without quotes if virtual-host addressing is required |
sessionToken | Unset | Include it for temporary session credentials and update before expiry |
For example, if a provider requires a specific region and virtual-host addressing:
{
"endpoint": "https://s3.example.com",
"bucket": "edgechat",
"accessKeyId": "YOUR_ACCESS_KEY",
"secretAccessKey": "YOUR_SECRET_KEY",
"region": "eu-west-1",
"forcePathStyle": false
}Files still pass through Worker authorization and AES-GCM storage encryption. S3 credentials never reach the browser. Invalid configuration fails explicitly instead of silently falling back to another bucket.
Manual Deployment
Skip this section when using Actions. From the project directory, run:
npx wrangler secret put EDGECHAT_S3 --config wrangler.tomlPaste the JSON at the prompt. Only for S3-only deployments without native R2, remove the [[r2_buckets]] block from the configuration you deploy, then deploy normally. Inject credentials through Secrets, never configuration files.
Migration and Returning to R2
Before moving an existing site between R2 and S3, or changing buckets:
- Pause uploads and file cleanup. Back up the database and the complete encryption keyring.
- Copy every object and its metadata to the target bucket, keeping object keys unchanged. Do not delete any encryption key referenced by historical ciphertext.
- Confirm the copy is complete before switching configuration and deploying. Verify both old and new files, then resume uploads and cleanup.
Cleanup only operates on the current backend. There is no automatic migration, dual read, or dual write. Administrators must arrange the copy and pause tasks themselves.
Return to Native R2
First copy files back to the target R2 bucket as described above. Set the same Actions Secret EDGECHAT_S3 to the plain text r2, then rerun 00 Deploy Worker. Actions restores the native R2 binding before switching backends.
Removing the GitHub Repository Secret does not remove the Secret already deployed to the Worker. Deleting the Repository Secret alone is not a rollback.
For manual deployment, restore and deploy the native R2 FILES binding first. Then run the wrangler secret put command above and enter r2.
Troubleshooting
- Upload permission errors: check the bucket name and read, write, delete, and list permissions.
- Signature or region errors: verify the endpoint, provider-required
region, and credential expiry. - Bucket hostname or path mismatch: select
forcePathStyleas required by the provider, without duplicating the bucket name in the endpoint. - New files work but old files do not: check object/metadata migration and the complete encryption keyring.
End-to-end acceptance with a real external S3 provider has not yet been completed. Verify compatibility with actual uploads, downloads, deletes, and storage scans for your provider.