La API de almacenamiento en StudioCMS proporciona una forma unificada de gestionar e interactuar con varios backends de almacenamiento. Abstrae las complejidades de los diferentes sistemas de almacenamiento, permitiendo a los desarrolladores trabajar con una interfaz consistente independientemente de la tecnología subyacente.
La API de almacenamiento está diseñada para ser flexible y extensible. Soporta múltiples backends de almacenamiento, incluyendo sistemas de archivos locales, servicios de almacenamiento en la nube y bases de datos. Los desarrolladores pueden elegir el backend de almacenamiento que mejor se adapte a sus necesidades y cambiar fácilmente entre ellos sin modificar el código de su aplicación.
La API de almacenamiento utiliza plugins de gestión para manejar diferentes backends de almacenamiento. Cada plugin de gestión implementa un sistema de almacenamiento específico y proporciona métodos para operaciones comunes como leer, escribir y eliminar archivos.
Un ejemplo de un gestor integrado en StudioCMS es el gestor no-op, que no realiza ninguna operación e indica a StudioCMS que no active ninguna de sus funciones de almacenamiento.
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';
/**
* Un servicio No-Op (sin operación) que implementa la interfaz StorageApiBuilderDefinition.
*
* Este servicio proporciona implementaciones placeholder para los endpoints de la API de almacenamiento,
* devolviendo una respuesta 501 No Implementado tanto para solicitudes POST como PUT.
*
* @typeParam C - El tipo de contexto.
* @typeParam R - El tipo de respuesta.
*/
exportdefaultclass
classNoOpStorageService<C, R>
Un servicio No-Op (sin operación) que implementa la interfaz StorageApiBuilderDefinition.
Este servicio proporciona implementaciones placeholder para los endpoints de la API de almacenamiento,
devolviendo una respuesta 501 No Implementado tanto para solicitudes POST como PUT.
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.
Para configurar un gestor de almacenamiento en StudioCMS, debes especificar el plugin de gestión deseado en tu archivo de configuración de StudioCMS. Para hacerlo, debes instalar el paquete del plugin de gestión y luego añadirlo a la propiedad storageManager en tu archivo studiocms.config.*.
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.