File Storage
Introduction
JCC Express MVC includes a Laravel-like storage layer in jcc-express-mvc/lib/Storage with a StorageManager and pluggable disk drivers.
The built-in export is:
Storage(singleton manager with default config)StorageManager(create your own configured manager)LocalDriver(filesystem driver)StorageUtils(path/mime helper utilities)
Import and basic usage
TypeScript
Available methods
On the manager (default disk):
exists(path)get(path)put(path, contents)putFile(path, buffer)delete(path)files(directory?)allFiles(directory?)directories(directory?)makeDirectory(path)size(path)copy(from, to)move(from, to)url(path)
On a disk driver (Storage.disk("name")), you also get:
deleteDirectory(directory)lastModified(path)temporaryUrl(path, expiration)
Working with disks
Pick a specific disk with disk(name):
TypeScript
Default behavior uses the configured default disk (local in the shipped config).
Default configuration
The shipped storage config includes:
local->./storage/apppublic->./storage/app/publicwith URL/storage
From lib/Storage:
TypeScript
Create your own manager
If you want custom disks or roots, instantiate StorageManager directly:
TypeScript
Upload helpers
StorageUtils includes helper methods:
generatePath(filename, directory?)storeUploadedFile(storageDriver, fileBuffer, filename, directory?)getMimeType(filename)
Example:
TypeScript
Notes
- Local driver
url(...)returns afile://URL for resolved path. temporaryUrl(...)currently returns regular local URL (no signed URL behavior yet).- Missing files are handled safely (
get->null,exists->false, etc.).
Summary
- Use
Storagefor quick default-disk operations. - Use
Storage.disk("public")for per-disk targeting. - Use
StorageManagerfor custom configuration. - Use
StorageUtilsto standardize upload paths and mime handling.
