Zum Inhalt springen

JavaScript Helpers

Dieser Inhalt ist noch nicht in deiner Sprache verfügbar.

The StudioCMS Storage API provides several JavaScript helpers to facilitate interaction with storage backends. These helpers simplify tasks such as resolving storage identifiers and keys, as well as providing type definitions for better type safety and code completion.

storage-api-example.ts
import {
resolveStorageIdentifier,
resolveStorageKey,
} from 'studiocms/storage-api';
const storageIdentifier = await resolveStorageIdentifier('storage-file://my-file.txt', {
baseUrl: 'https://example.com/', // Use the value of `site` from "astro:config/server"
});
const storageKey = await resolveStorageKey('my-file.txt', {
baseUrl: 'https://example.com/', // Use the value of `site` from "astro:config/server"
});
storage-api-types.ts
import type {
ContextJsonBody,
AuthorizationType,
ParsedContext,
UrlMetadata,
UrlMapping,
ContextHandler,
ContextHandlerFn,
ContextDriverDefinition,
StorageAPIEndpointFn,
StorageApiBuilderDefinition,
UrlMappingDatabaseDefinition,
UrlMappingServiceDefinition,
APICoreDefinition
} from 'studiocms/storage-api';