콘텐츠로 이동

JavaScript Helpers

이 콘텐츠는 아직 번역되지 않았습니다.

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';