Storage Providers
Local Storage Provider

Local Storage Provider

The Montagix SDK offers a range of storage solutions to fit different use cases. The LocalStorageProvider is tailored for client-side rendering or development environments, allowing developers to work with assets directly from the client's local storage.

Overview

The LocalStorageProvider implements the CustomStorageProvider abstract class. This specific provider focuses on integrating with the browser's local storage mechanisms, making it straightforward for developers to store, retrieve, and manage assets during the development process.

Key Functions

  • Put: If the source is an instance of the File object, the function creates an Object URL representing the file. If it's a string URL, it directly returns it.
  • Delete: Utilizes the URL.revokeObjectURL method to release an existing Object URL and free up system resources.
  • Serialize and Deserialize: These functions are designed for storing provider configurations and restoring them from a saved state.

Benefits

  1. Simplicity: Leveraging the browser's native functionalities ensures smooth and quick operations without the overhead of external integrations.
  2. Rapid Development: An excellent choice for developers who want a quick and straightforward solution to store assets while building and testing applications.
  3. Client-Side: Being tailored for client-side rendering, it offers seamless integration with front-end frameworks and libraries.

Limitations

  • Server Side Rendering (SSR): The LocalStorageProvider is not suitable for server-side rendering, as they do not share the same context. This means that assets stored using this provider are not accessible during SSR processes.
  • Persistence: Data stored in local storage is inherently temporary. Developers should be aware that data can be lost based on browser policies or user actions.
  • Limited Media Formats: The range of media formats supported by the LocalStorageProvider is constrained by the browser's capabilities, meaning certain media types might not be accessible or playable across all browsers.

Getting Started

While the LocalStorageProvider simplifies local asset management, developers should be cautious when choosing storage providers. Always consider the longevity and accessibility of your stored data.


Note: The LocalStorageProvider is primarily recommended for development purposes. Before deploying applications to production, ensure that a more permanent and robust storage solution, like the S3StorageProvider, is in place.


Installation

const engine = new Engine({
  resolution: [1080, 1920],
  storageProvider: new LocalStorageProvider(),
});