Skip to main content
Sonamu allows you to easily handle file uploads through the @upload decorator.

File Upload Overview

@upload Decorator

Automatic file parsing Single/multiple file support

UploadedFile Class

File info access saveToDisk() method

Storage Manager

local, S3, GCS integration Flexible storage

Auto URL Generation

Public URL Signed URL

@upload Decorator

Basic Usage

Multiple File Upload

Storage Configuration

Storage Manager

Sonamu provides a Storage Manager that manages multiple storages in an integrated way.

Environment Variable Setup

Disk Selection

Save to Specific Disk

Fastify Multipart Setup (Required)

Since Sonamu uses Fastify internally, you need to register the multipart plugin.

Server Configuration

Sonamu’s @upload decorator automatically handles Fastify multipart.

File Validation

Size and Type Validation

Practical Examples

Profile Image Upload

Post Attachments

Client Examples

HTML Form

React Example

Cautions

Cautions when setting up file upload: 1. Fastify multipart plugin must be registered 2. @upload is used independently (without @api) 3. Set file size limits 4. MIME type validation 5. Check Storage configuration

Next Steps

UploadedFile Class

File info and methods

Saving Files

saveToDisk details

URL Generation

Generating URLs

@api Decorator

API basic usage