Skip to main content
Sonamu supports multiple storage drivers based on Flydrive. You can use the local file system (fs) and AWS S3 with the same interface.

Supported Drivers

fs (File System)

Local file system

s3 (AWS S3)

AWS S3 compatible storage

fs Driver

Stores files in the local file system.

Basic Configuration

Configuration Options

File storage location
Recommended: Relative path from project root

Practical Examples

Development Environment

Usage:

Static File Serving

You need to serve static files with Fastify:
Result:

s3 Driver

Stores files in AWS S3 or compatible storage.

Basic Configuration

Required Environment Variables

Configuration Options

AWS credentials
How to obtain:
  1. AWS Console → IAM
  2. Create user
  3. Grant S3 permissions (AmazonS3FullAccess)
  4. Create Access Key

Practical Examples

Basic S3 Configuration

Usage:

CloudFront CDN Integration

Benefits:
  • Fast transfer speed (edge locations)
  • Reduced bandwidth costs
  • Caching

Public Bucket Configuration

To make an S3 bucket public:
Caution: Use private buckets for sensitive data

S3 Compatible Storage

Cloudflare R2

Features:
  • Free egress (no transfer costs)
  • S3 API compatible
  • Cloudflare network

MinIO (Self-hosted)

Driver Comparison

Practical Strategies

Development/Production Separation

Multi-Bucket Strategy

Usage:

Cautions

Cautions when configuring drivers:
  1. Environment variable management: Never hardcode
  2. fs urlBuilder required: fs driver requires urlBuilder
  3. S3 permissions check: Grant S3 permissions to IAM user
  4. Bucket name uniqueness: S3 bucket names must be globally unique
  5. Region matching: bucket and region must match

Next Steps

Storage Manager

Managing multiple disks

File Operations

File upload and download

URL Builder

Generating file URLs