The Storage API in StudioCMS provides a unified way to manage and interact with various storage backends. It abstracts the complexities of different storage systems, allowing developers to work with a consistent interface regardless of the underlying technology.
The Storage API is designed to be flexible and extensible. It supports multiple storage backends, including local file systems, cloud storage services, and databases. Developers can choose the storage backend that best fits their needs and easily switch between them without changing their application code.
The Storage API uses manager plugins to handle different storage backends. Each manager plugin implements a specific storage system and provides methods for common operations such as reading, writing, and deleting files.
An example of a manager built-in to StudioCMS is the no-op manager, which performs no operations and tells StudioCMS not to enable any of its storage features.
This type defines the possible authorization types
that can be used in storage manager API requests.
AuthorizationType,
interfaceContextDriverDefinition<C, R>
Context Driver Definition interface.
This interface defines the structure and methods for a context driver,
including parsing the context, building responses, and handling endpoints.
ContextDriverDefinition,
typeStorageAPIEndpointFn<C, R> = (context: C) =>Promise<R>
Storage API Endpoint Function type.
This type defines a function that takes a context of type C
and returns a Promise resolving to a response of type R.
StorageAPIEndpointFn,
interfaceStorageApiBuilderDefinition<C, R>
Storage API Builder Definition interface.
This interface defines the structure and methods for building storage API endpoints,
including handling POST and PUT requests.
StorageApiBuilderDefinition,
(alias) interfaceUrlMappingServiceDefinition
importUrlMappingServiceDefinition
URL Mapping Service Definition interface.
This interface defines the structure and methods for the URL Mapping Service,
which manages the mapping between storage file identifiers and their corresponding URLs.
UrlMappingServiceDefinition,
}from'studiocms/storage-manager/definitions';
/**
* A No-Op Storage Service that implements the StorageApiBuilderDefinition interface.
*
* This service provides placeholder implementations for storage API endpoints,
* returning a 501 Not Implemented response for both POST and PUT requests.
*
* @typeParam C - The context type.
* @typeParam R - The response type.
*/
exportdefaultclass
classNoOpStorageService<C, R>
A No-Op Storage Service that implements the StorageApiBuilderDefinition interface.
This service provides placeholder implementations for storage API endpoints,
returning a 501 Not Implemented response for both POST and PUT requests.
NoOpStorageService<
function (typeparameter) CinNoOpStorageService<C, R>
C,
function (typeparameter) RinNoOpStorageService<C, R>
R>implements
interfaceStorageApiBuilderDefinition<C, R>
Storage API Builder Definition interface.
This interface defines the structure and methods for building storage API endpoints,
including handling POST and PUT requests.
StorageApiBuilderDefinition<
function (typeparameter) CinNoOpStorageService<C, R>
C,
function (typeparameter) RinNoOpStorageService<C, R>
This interface defines the structure and methods for the URL Mapping Service,
which manages the mapping between storage file identifiers and their corresponding URLs.
UrlMappingServiceDefinition;
constructor(
driver: ContextDriverDefinition<C, R>
driver:
interfaceContextDriverDefinition<C, R>
Context Driver Definition interface.
This interface defines the structure and methods for a context driver,
including parsing the context, building responses, and handling endpoints.
ContextDriverDefinition<
function (typeparameter) CinNoOpStorageService<C, R>
C,
function (typeparameter) RinNoOpStorageService<C, R>
R>,
urlMappingService: UrlMappingServiceDefinition
urlMappingService:
(alias) interfaceUrlMappingServiceDefinition
importUrlMappingServiceDefinition
URL Mapping Service Definition interface.
This interface defines the structure and methods for the URL Mapping Service,
which manages the mapping between storage file identifiers and their corresponding URLs.
To configure a storage manager in StudioCMS, you need to specify the desired manager plugin in your StudioCMS configuration file. To do so you must install the manager plugin package and then add it to the storageManager property in your studiocms.config.* file.
A utility function to define the StudioCMS config object.
This function is used to define the optional StudioCMS
config object in the Astro project root. The expected file
name is studiocms.config.mjs. And it should be adjacent
to the Astro project's astro.config.mjs file.
StudioCMS will attempt to import this file and use the default
export as the StudioCMS config object automatically if it exists.
Using this function is optional, but it can be useful for IDEs
to provide better intellisense and type checking.
A utility function to define the StudioCMS config object.
This function is used to define the optional StudioCMS
config object in the Astro project root. The expected file
name is studiocms.config.mjs. And it should be adjacent
to the Astro project's astro.config.mjs file.
StudioCMS will attempt to import this file and use the default
export as the StudioCMS config object automatically if it exists.
Using this function is optional, but it can be useful for IDEs
to provide better intellisense and type checking.