Skip to content

StorageAdapterBaseInterface

Defined in: packages/core/src/media/types.ts:113

Shared interface implemented by all storage adapters.

Defines the minimum contract — name, type, mediaCollections, and the four lifecycle methods (createMediaDocument, deleteMedia, getUrl, uploadFile) — that every adapter must satisfy regardless of protocol.

admin: object

Defined in: packages/core/src/media/types.ts:129

softDelete: boolean

When true, delete operations set deleted: true on the media document instead of physically removing the file. The file remains in storage until a scheduled cleanup job purges it.

false

mediaCollections: MediaCollectionConfig<BaseFieldMeta, MediaCollectionMeta, string, string, ComponentHKT>[]

Defined in: packages/core/src/media/types.ts:127

Processed media collections ready for schema generation and admin panel.

The adapter validates, augments, and returns these collections. Each collection is tagged with meta.storageAdapterName equal to this adapter’s name. Core merges all collections from all adapters into VexConfig.mediaCollections — separate from user-defined collections.


readonly name: string

Defined in: packages/core/src/media/types.ts:115

Protocol name — tells the admin panel what the identifier of this storage adapter is.


readonly type: "presigned-url"

Defined in: packages/core/src/media/types.ts:117

Protocol type — tells the admin panel how to upload files.

createMediaDocument<TDataModel>(ctx, args): Promise<string>

Defined in: packages/core/src/media/types.ts:144

Creates a media document in Convex after the file is uploaded. All adapters must use this exact signature.

TDataModel extends GenericDataModel = GenericDataModel

GenericMutationCtx<TDataModel>

Record<string, unknown>

string

string

string

string

number

string

Promise<string>


deleteMedia<TDataModel>(ctx, args): Promise<boolean>

Defined in: packages/core/src/media/types.ts:161

Deletes a media document and its file from storage. All adapters must use this exact signature.

TDataModel extends GenericDataModel = GenericDataModel

GenericMutationCtx<TDataModel>

string

string

boolean

Promise<boolean>


getUrl<TDataModel>(ctx, args): Promise<GetUrlReturn>

Defined in: packages/core/src/media/types.ts:170

Returns a URL for a media file. All adapters must use this exact signature.

TDataModel extends GenericDataModel = GenericDataModel

GenericQueryCtx<TDataModel>

string

string

Promise<GetUrlReturn>


uploadFile(file, uploadUrl): Promise<{[key: string]: unknown; storageId: string; url?: string; }>

Defined in: packages/core/src/media/types.ts:192

Uploads a file to the storage backend and returns the storage ID.

This is a pure JS function that can be called from any framework (React, Next.js, Svelte, etc.) or even directly in the browser.

any

The file to upload

string

The presigned URL from generateUploadUrl

Promise<{[key: string]: unknown; storageId: string; url?: string; }>

Promise resolving to { storageId, url, … } with adapter-specific fields

// React component
const { storageId } = await adapter.uploadFile(file, uploadUrl);
await createMediaDocument({ storageId, ... });