Interface Definition
Properties
The absolute path to the location where files will be stored on the server. This is the root directory for all file storage operations.
The version identifier for the module configuration.
Usage
TheModuleOptions interface is used when configuring the nuxt-file-storage module in your nuxt.config.ts file. These options are set under the fileStorage key.
It’s recommended to use environment variables for the
mount path to keep your configuration flexible across different environments (development, staging, production).Examples
Basic Configuration
Using Environment Variables (Recommended)
Production Configuration
Different Storage Paths per Environment
Using Path Module for Cross-Platform Compatibility
After configuring the module, the
mount path becomes the root directory for all file storage operations. When using functions like storeFileLocally(), paths are relative to this mount point.Best Practices
- Use Environment Variables: Store sensitive paths in environment variables rather than hardcoding them
- Absolute Paths: Always use absolute paths for the
mountoption to avoid ambiguity - Permissions: Ensure the specified directory has appropriate read/write permissions for your application
- Backup Strategy: Keep the storage directory in mind when planning your backup strategy
- Security: Don’t expose the storage directory through your web server’s public directory