Skip to content

File Uploads ​

ferrixd can host files your users share — images, documents and voice messages — so web and mobile clients don't depend on third-party pastebins. It implements soju.im/FILEHOST, which clients such as gamja, Goguma and senpai already understand.

Enabling it ​

Uploads are served by the built-in HTTP(S) server, [web]:

toml
[web]
bind = "0.0.0.0:8443"
# tls = true                         # default: HTTPS with the [tls] certificate
# public_url = "https://chat.example.org"   # when behind a reverse proxy

[filehost]
enabled = true
max_bytes = 26214400                 # 25 MiB per file
quota_bytes = 524288000              # 500 MiB per account (0 = unlimited)
uploads_per_hour = 60
retention_days = 30                  # 0 = keep forever
voice_max_secs = 300                 # longest Ogg/Opus voice message
# allowed_types = ["image/*", "audio/ogg", "application/pdf"]

[filehost.storage]
kind = "local"
path = "/var/lib/ferrixd/uploads"

The [web] listener uses the same certificate as the IRC TLS listeners (including automatic reloads and ACME). Plain HTTP (tls = false) is only accepted on a loopback address, for a TLS-terminating reverse proxy in front; set public_url to the address clients use.

Connected clients see the upload endpoint in ISUPPORT:

:irc.example.org 005 alice … soju.im/FILEHOST=https://chat.example.org/upload :are supported by this server

The protocol ​

RequestResult
POST /upload with Authorization: Basic <account:password>, Content-Type and optionally Content-Disposition: attachment; filename="…"201 Created, Location: <file URL> (also the body)
HEAD / OPTIONS /uploadAccept-Post lists the accepted types; CORS preflight for browser clients
GET /files/<id>/<name>the file — no authentication, the random id is the capability
DELETE /files/<id> (Basic auth)204 — owners can delete their uploads
sh
curl -u alice:secret -H 'Content-Type: image/png' \
     -H 'Content-Disposition: attachment; filename="cat.png"' \
     --data-binary @cat.png https://chat.example.org/upload

Errors: 401 (credentials; ten failures per IP within ten minutes lock the IP out for the rest of the window), 411 (chunked uploads — send a Content-Length), 413 (too large, over quota, or a voice message that is too long / not Ogg), 415 (type not allowed), 429 (upload rate), 503 (storage failure).

Safety ​

  • Only types on allowed_types are accepted; HTML and SVG are not in the default list.
  • Downloads carry X-Content-Type-Options: nosniff and a sandboxing Content-Security-Policy, and are shown inline only for images, audio, video, PDF and plain text — everything else downloads as an attachment. An uploaded file can never run script in your server's origin.
  • File names are sanitised (no paths, quotes or control characters).
  • Voice messages (audio/ogg, audio/opus) are checked against voice_max_secs by reading the Ogg stream's final granule position.
  • Expired files are purged hourly; dropping an account deletes its uploads.

S3-compatible storage ​

Any S3-compatible object store works — AWS S3, MinIO, Garage, Cloudflare R2, Backblaze B2 …:

toml
[filehost]
enabled = true
index = "/var/lib/ferrixd/uploads.db"   # required with S3

[filehost.storage]
kind = "s3"
endpoint = "https://s3.eu-central-1.amazonaws.com"
region = "eu-central-1"
bucket = "chat-uploads"
access_key_env = "FERRIXD_S3_ACCESS_KEY"
secret_key_env = "FERRIXD_S3_SECRET_KEY"
# path_style = true     # <endpoint>/<bucket>/… (default); false for <bucket>.<host>
# prefix = "uploads"

Credentials are read from the named environment variables. ferrixd signs requests with AWS Signature V4 and proxies downloads, so the bucket can stay private. The SQLite index records owner, name, type, size and upload time for quotas and retention.

Dual-licensed under MIT or Apache-2.0.