StorageFolder constructor
Represents a scoped logical folder within the application's storage hierarchy.
The StorageFolder class serves as a bridge between the declarative storage model (StorageFolderModel) and the operational storage layer (StorageFolderImplement), providing unified access to upload, download, and local caching features within a defined path context.
Each instance of StorageFolder represents a concrete directory (or bucket segment) whose full path is derived from the combination of parent and current. Paths are automatically normalized to ensure cross-platform consistency.
This abstraction enables platform-independent file operations while maintaining predictable path resolution, making it ideal for scalable storage architectures.
Responsibilities
- Provides access to upload operations through upload.
- Provides access to download operations through download.
- Provides access to local cache operations through local.
- Automatically constructs a normalized
fullPathfor all operations.
Example
final folder = StorageFolder(parent: 'media', current: 'images');
// Upload a file to 'media/images'
await folder.upload.add(file);
// Download or retrieve a file by ID
final downloaded = await folder.download.get('photo_123');
// Access locally cached version if available
final localFile = await folder.local.get('photo_123');
Path Example
parent: "users/42"
current: "avatars"
fullPath → "users/42/avatars"
Implementation
StorageFolder({super.parent, required super.current});