HUB
Sign inSign up

florianbloechinger/fileserver

By florianbloechinger

•Updated 6 months ago

Self-hosted file uploads, signed download URLs, owner-scoped deduplication.

Image
Web servers
0

181

florianbloechinger/fileserver repository overview

⁠BeTechSpark File Server

Self-hosted file uploads, signed download URLs, owner-scoped deduplication, and TUS resumable uploads — the ingestion layer for the BeTechSpark Media Platform⁠. Built in Rust for production workloads.

  • Documentation: betechspark.com/docs⁠
  • TypeScript SDKs: @betechspark/fileserver-client, @betechspark/fileserver-server, @betechspark/fileserver-react on npm⁠

Pair with Image Proxy⁠ for end-to-end media: upload here, transform and deliver images there.

⁠Features

  • Multipart uploads — POST /files with metadata (owner, visibility, MIME type)
  • Signed URLs — HMAC download links with expiry (POST /sign, ?exp=&sig=)
  • Deduplication — content-addressed blobs; same bytes + same owner → deduped: true
  • TUS — resumable uploads for large files
  • Flexible storage — local filesystem or S3-compatible object storage
  • Flexible metadata — in-memory (trial), PostgreSQL, or SurrealDB
  • SDKs — HTTP client, Node server helpers, React upload hooks

⁠Quick start (5-minute trial)

Minimal setup: in-memory metadata and local filesystem storage. No Postgres or S3 required.

docker run -d --name fileserver \
  -p 3004:3004 \
  -e DATABASE_KIND=inmemory \
  -e STORAGE_KIND=fs \
  -e FILESERVER_SIGNING_SECRET=change-me-in-production \
  -e RUST_LOG=info \
  florianbloechinger/fileserver:latest
curl http://localhost:3004/health
⁠Upload a file
curl -X POST http://localhost:3004/files \
  -F "file=@./photo.jpg" \
  -F "owner_id=alice" \
  -F "mime_type=image/jpeg" \
  -F "visibility=public"

Example response:

{
  "id": "550e8400-e29b-41d4-a716-446655440000",
  "hash": "blake3:…",
  "deduped": false
}

Use the returned id with Image Proxy (fileserver/<id> source keys) or download via GET /files/:id.

⁠Docker Compose
services:
  fileserver:
    image: florianbloechinger/fileserver:latest
    ports:
      - "3004:3004"
    environment:
      FILESERVER_PORT: "3004"
      DATABASE_KIND: inmemory
      STORAGE_KIND: fs
      FILESERVER_SIGNING_SECRET: change-me-in-production
      RUST_LOG: info
    volumes:
      - fileserver_data:/app/data
      - fileserver_tmp:/app/tmp

volumes:
  fileserver_data:
  fileserver_tmp:

Full guides (persistence, S3, Kubernetes, SDKs): File Server docs⁠.


⁠Image tags

TagDescription
latestLatest successful build from main
main-<sha>Specific commit on main (e.g. main-abc1234)
v1.2.3 / 1.2.3Release tags when published

⁠API overview

EndpointDescription
GET /healthHealth check
POST /filesUpload a file (multipart)
GET /files/:idDownload by logical file ID
HEAD /files/:idMetadata / existence check
DELETE /files/:idDelete a file (owner-scoped)
POST /signCreate a signed download URL
POST /files/tusTUS resumable upload (create)
PATCH /files/tus/:idTUS upload chunks

See the API reference⁠ for request/response details.


⁠Essential environment variables

VariableDefaultDescription
FILESERVER_PORT3004HTTP port
FILESERVER_HOST0.0.0.0Bind address
DATABASE_KIND—inmemory, postgres, surrealdb, …
DATABASE_URL—Postgres connection string when using postgres
STORAGE_KIND—fs (local disk) or s3
FILESERVER_STORAGE_ROOT./dataBlob root for filesystem storage
FILESERVER_SIGNING_SECRET(required)HMAC secret for signed URLs — set a strong value in production
S3_*—S3 endpoint, bucket, credentials when STORAGE_KIND=s3
RUST_LOG—Log level (e.g. info, debug)

For the full list, see Reference: env vars⁠.


⁠Pair with Image Proxy

Typical media stack on one host. Share the blob volume and set FILESERVER_BLOB_SOURCE_PREFIX so Image Proxy reads objects/<hash> from disk (not via S3):

services:
  fileserver:
    image: florianbloechinger/fileserver:latest
    ports:
      - "3004:3004"
    environment:
      DATABASE_KIND: inmemory
      STORAGE_KIND: fs
      FILESERVER_STORAGE_ROOT: /app/data
      FILESERVER_SIGNING_SECRET: change-me-in-production
      RUST_LOG: info
    volumes:
      - media_blobs:/app/data

  imageproxy:
    image: florianbloechinger/imageproxy:latest
    ports:
      - "3001:3001"
    environment:
      DATABASE_URL: memory
      IMAGE_SOURCES_ENABLED: filesystem,url,fileserver
      FILESERVER_BASE_URL: http://fileserver:3004
      FILESERVER_BLOB_SOURCE_PREFIX: fs/data
      FS_IMAGE_ROOTS: /app/data
      JWT_SECRET: change-me-in-production
      RUST_LOG: info
    volumes:
      - media_blobs:/app/data:ro
    depends_on:
      - fileserver

volumes:
  media_blobs:

After upload, transform via GET /asset/<base64url("fileserver/<uuid>")>?w=800&f=webp on port 3001.

⁠Signed download URL
EXP=$(($(date +%s) + 300))
curl -s -X POST http://localhost:3004/sign \
  -H "Content-Type: application/json" \
  -d "{\"file_id\":\"<uuid>\",\"owner_id\":\"alice\",\"perm\":\"read\",\"exp_unix\":$EXP}"

Flow: app uploads to File Server → Image Proxy transforms via fileserver/<id> or catalog /image/:id when metadata is shared.

More: Media platform integration⁠.


⁠Platform integration

ComponentRole
File Server (this image)Uploads, metadata, signed URLs, TUS
Image Proxy⁠Transform, cache, and deliver images
@betechspark npm packagesHTTP client, server middleware, React upload hooks


BeTechSpark — self-hosted media stack. You own the infrastructure, data, and delivery.

Tag summary

Content type

Image

Digest

sha256:622b25b1b…

Size

34 MB

Last updated

6 months ago

docker pull florianbloechinger/fileserver