Skip to content

StorageAdapterBaseInterface

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

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:130

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, Record<string, AdminField<BaseFieldMeta>>, ComponentHKT>[]

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

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:116

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:118

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

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

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

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:162

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:171

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:193

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, ... });