Local Filesystem
The Local Filesystem module (@zumito-team/local-filesystem) is a FileManager implementation that stores files on the local filesystem. Ideal for development, testing, and self-hosted bots that don’t need cloud storage.
Installation
Section titled “Installation”npm install @zumito-team/local-filesystemAs a Zumito module
Section titled “As a Zumito module”import { LocalFilesystemModule } from '@zumito-team/local-filesystem';
export const config = { bundles: [ { path: 'node_modules/@zumito-team/local-filesystem', options: { basePath: './data/uploads', publicUrlBase: 'https://example.com/uploads', }, }, ],};Direct usage
Section titled “Direct usage”import { LocalFilesystemModule, ServiceContainer, LocalFileManager } from '@zumito-team/local-filesystem';
new LocalFilesystemModule({ basePath: './data/uploads', publicUrlBase: 'https://example.com/uploads',});
const fm = ServiceContainer.getService(LocalFileManager);CRUD operations
Section titled “CRUD operations”const fm = ServiceContainer.getService(LocalFileManager);
// Upload (creates directories automatically)const url = await fm.put('images/banner.png', buffer, 'image/png');
// Downloadconst data = await fm.get('images/banner.png');
// Check existenceconst exists = await fm.exists('images/banner.png');
// List by prefixconst files = await fm.list('images/');
// Deleteawait fm.delete('images/banner.png');URL generation
Section titled “URL generation”If publicUrlBase is configured, URLs are built as {publicUrlBase}/{key}:
// With publicUrlBase = 'https://example.com/uploads'const url = await fm.getUrl('images/banner.png');// => 'https://example.com/uploads/images/banner.png'Without publicUrlBase, URLs use the file:// protocol:
// => 'file:///absolute/path/to/data/uploads/images/banner.png'Configuration
Section titled “Configuration”| Option | Type | Required | Description |
|---|---|---|---|
basePath | string | yes | Root directory for file storage. |
publicUrlBase | string | no | Base URL for building public URLs (e.g., CDN or nginx reverse proxy). |
Security
Section titled “Security”The LocalFileManager normalizes all paths and blocks access outside the configured basePath. Any ../ traversal attempts are silently resolved to the root directory.
Dependencies
Section titled “Dependencies”@zumito-team/file-manager— FileManager abstract contract.zumito-framework
Related modules
Section titled “Related modules”- File Manager — Abstract contract this module implements.
- S3 Assets — Alternative S3-compatible storage implementation.