Skip to content

Configuration

Stowry uses a YAML configuration file with environment variable overrides.

Configuration values are loaded in this order (later sources override earlier ones):

  1. Default values
  2. Configuration file (config.yaml)
  3. Environment variables (STOWRY_ prefix)
  4. Command-line flags
# Server configuration
server:
port: 5708 # HTTP server port (default: 5708)
mode: store # Server mode: store, static, spa (default: store)
# Database configuration
database:
type: sqlite # Database type: sqlite, postgres (default: sqlite)
dsn: stowry.db # Connection string or file path
table: stowry_metadata # Metadata table name (default: stowry_metadata)
auto_migrate: true # Automatically create/update tables on startup (default: false)
# Storage configuration
storage:
path: ./data # Directory for file storage (default: ./data)
# Authentication configuration
auth:
region: us-east-1 # AWS region for signature verification
service: s3 # AWS service name (default: s3)
keys: # List of access keys
- access_key: AKIAIOSFODNN7EXAMPLE
secret_key: wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY
# Access control
access:
public_read: false # Allow unauthenticated read access (default: false)
public_write: false # Allow unauthenticated write access (default: false)
# Logging
log:
level: info # Log level: debug, info, warn, error (default: info)
OptionTypeDefaultDescription
portint5708HTTP server port
modestringstoreServer mode (store, static, spa)
OptionTypeDefaultDescription
typestringsqliteDatabase type (sqlite, postgres)
dsnstringstowry.dbConnection string
tablestringstowry_metadataMetadata table name
auto_migrateboolfalseAutomatically create/update database schema on startup

Migration Options:

  1. Auto-migrate (recommended for development): Set auto_migrate: true in config
  2. CLI migration: Run stowry init before starting the server
  3. Manual SQL: Execute the schema SQL below directly in your database
-- Table name can be anything - just ensure it matches database.table in your config
CREATE TABLE IF NOT EXISTS stowry_metadata (
id UUID PRIMARY KEY DEFAULT gen_random_uuid(),
path TEXT NOT NULL UNIQUE,
content_type TEXT NOT NULL,
etag TEXT NOT NULL,
file_size_bytes BIGINT NOT NULL,
created_at TIMESTAMPTZ NOT NULL DEFAULT NOW(),
updated_at TIMESTAMPTZ NOT NULL DEFAULT NOW(),
deleted_at TIMESTAMPTZ,
cleaned_up_at TIMESTAMPTZ
);
CREATE INDEX IF NOT EXISTS idx_stowry_metadata_deleted_at
ON stowry_metadata (deleted_at)
WHERE (deleted_at IS NOT NULL);
CREATE INDEX IF NOT EXISTS idx_stowry_metadata_pending_cleanup
ON stowry_metadata (deleted_at, cleaned_up_at)
WHERE (deleted_at IS NOT NULL AND cleaned_up_at IS NULL);
CREATE INDEX IF NOT EXISTS idx_stowry_metadata_active_list
ON stowry_metadata (created_at, path)
WHERE (deleted_at IS NULL);
-- Table name can be anything - just ensure it matches database.table in your config
CREATE TABLE IF NOT EXISTS stowry_metadata (
id TEXT NOT NULL PRIMARY KEY,
path TEXT NOT NULL UNIQUE,
content_type TEXT NOT NULL,
etag TEXT NOT NULL,
file_size_bytes INTEGER NOT NULL,
created_at TEXT NOT NULL,
updated_at TEXT NOT NULL,
deleted_at TEXT,
cleaned_up_at TEXT
);
CREATE INDEX IF NOT EXISTS idx_stowry_metadata_deleted_at
ON stowry_metadata (deleted_at);
CREATE INDEX IF NOT EXISTS idx_stowry_metadata_pending_cleanup
ON stowry_metadata (deleted_at, cleaned_up_at);
CREATE INDEX IF NOT EXISTS idx_stowry_metadata_active_list
ON stowry_metadata (created_at, path);

SQLite DSN Examples:

dsn: stowry.db # File-based database
dsn: :memory: # In-memory (testing only)
dsn: /var/lib/stowry/db # Absolute path

PostgreSQL DSN Examples:

dsn: postgres://user:password@localhost:5432/stowry
dsn: postgres://user:password@localhost:5432/stowry?sslmode=disable
dsn: host=localhost port=5432 user=stowry password=secret dbname=stowry
OptionTypeDefaultDescription
pathstring./dataDirectory for file storage

The storage directory is created automatically if it doesn’t exist. Files are organized by their path, maintaining the original directory structure.

OptionTypeDefaultDescription
regionstringus-east-1AWS region for signature verification
servicestrings3AWS service name
keyslist[]List of access key pairs

Multiple Keys:

auth:
keys:
- access_key: KEY1
secret_key: SECRET1
- access_key: KEY2
secret_key: SECRET2
OptionTypeDefaultDescription
public_readboolfalseAllow unauthenticated GET requests
public_writeboolfalseAllow unauthenticated PUT/DELETE requests

Access Control Matrix:

public_readpublic_writeGETPUTDELETE
falsefalseAuth requiredAuth requiredAuth required
truefalsePublicAuth requiredAuth required
truetruePublicPublicPublic
falsetrueAuth requiredPublicPublic
OptionTypeDefaultDescription
levelstringinfoMinimum log level

Log levels: debug, info, warn, error

All configuration options can be set via environment variables using the STOWRY_ prefix with underscores replacing dots.

Config PathEnvironment Variable
server.portSTOWRY_SERVER_PORT
server.modeSTOWRY_SERVER_MODE
database.typeSTOWRY_DATABASE_TYPE
database.dsnSTOWRY_DATABASE_DSN
database.tableSTOWRY_DATABASE_TABLE
database.auto_migrateSTOWRY_DATABASE_AUTO_MIGRATE
storage.pathSTOWRY_STORAGE_PATH
auth.regionSTOWRY_AUTH_REGION
access.public_readSTOWRY_ACCESS_PUBLIC_READ
access.public_writeSTOWRY_ACCESS_PUBLIC_WRITE
log.levelSTOWRY_LOG_LEVEL

Example:

Terminal window
STOWRY_SERVER_PORT=8080 \
STOWRY_DATABASE_TYPE=postgres \
STOWRY_DATABASE_DSN="postgres://localhost/stowry" \
./stowry serve

Global flags available for all commands:

Terminal window
--config string Config file path (default "config.yaml")
--db-type string Database type (sqlite, postgres)
--db-dsn string Database connection string
--db-table string Database table name
--storage-path string Storage directory path

Example:

Terminal window
./stowry serve --config /etc/stowry/config.yaml --db-type postgres
server:
port: 5708
mode: store
database:
type: sqlite
dsn: dev.db
auto_migrate: true
storage:
path: ./uploads
access:
public_read: true
public_write: true
log:
level: debug
server:
port: 5708
mode: store
database:
type: postgres
dsn: postgres://stowry:${DB_PASSWORD}@db.example.com:5432/stowry?sslmode=require
table: stowry_metadata
auto_migrate: true # Or run 'stowry init' manually before first start
storage:
path: /var/lib/stowry/data
auth:
region: us-east-1
service: s3
keys:
- access_key: ${STOWRY_ACCESS_KEY}
secret_key: ${STOWRY_SECRET_KEY}
access:
public_read: false
public_write: false
log:
level: info
server:
port: 80
mode: static
database:
type: sqlite
dsn: metadata.db
auto_migrate: true
storage:
path: /var/www/html
access:
public_read: true
public_write: false
server:
port: 3000
mode: spa
database:
type: sqlite
dsn: app.db
auto_migrate: true
storage:
path: ./dist
access:
public_read: true
public_write: false