Storage Manager Overview
Unified Interface
Single API Multiple storage support
Driver System
local, s3, gcs Extensible
saveToDisk()
Easy saving Auto URL generation
Disk Management
Multiple disk configuration Purpose-based separation
saveToDisk() Method (Recommended)
Basic Usage
ThesaveToDisk() method of BufferedFile is the simplest way to save files.
Disk Selection
Using Storage Manager Directly
Basic Usage
You can use Storage Manager directly whensaveToDisk() cannot be used.
resolveUploadContentType turns MIME types outside the allow-list (HTML, SVG, and so on) into application/octet-stream, so the file is stored with the same Content-Type that saveToDisk would use. A key built from the original filename keeps extensions such as .html, so if you serve the fs disk statically, also set up createUploadStaticHeaders.
Using Specific Disk
Storage Configuration
storage.config.ts
Storage Driver API
put() - Save File
key: string- Storage pathdata: Uint8Array- File dataoptions: { contentType?: string }- Options
get() - Read File
delete() - Delete File
exists() - Check File Existence
getUrl() - Generate Public URL
getSignedUrl() - Generate Signed URL
Practical Examples
Date-based Folder Structure
User-based Folder Structure
Category-based Disk Selection
Image Optimization Before Saving
Save to Multiple Disks Simultaneously
File Deletion
Delete File
Check Existence Before Deletion
Advanced Usage
Streaming Upload (Large Files)
For large files, use@upload({ consume: "stream" }). Files are streamed directly to the specified storage destination. Access the already-uploaded file info via context.uploadedFiles.
Saving File Metadata
Cautions
Next Steps
File Upload Setup
@upload decorator
BufferedFile Class
File info access
URL Generation
Generating URLs
@api Decorator
API basic usage