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.
- StorageAdapterPresignedUrlInterface for the presigned-URL sub-interface
- StorageAdapterPresignedUrl for the abstract base class
Extended by
Section titled “Extended by”Properties
Section titled “Properties”admin:
object
Defined in: packages/core/src/media/types.ts:130
softDelete
Section titled “softDelete”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.
Default
Section titled “Default”falsemediaCollections
Section titled “mediaCollections”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.
readonlyname:string
Defined in: packages/core/src/media/types.ts:116
Protocol name — tells the admin panel what the identifier of this storage adapter is.
readonlytype:"presigned-url"
Defined in: packages/core/src/media/types.ts:118
Protocol type — tells the admin panel how to upload files.
Methods
Section titled “Methods”createMediaDocument()
Section titled “createMediaDocument()”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.
Type Parameters
Section titled “Type Parameters”TDataModel
Section titled “TDataModel”TDataModel extends GenericDataModel = GenericDataModel
Parameters
Section titled “Parameters”GenericMutationCtx<TDataModel>
adapterFields?
Section titled “adapterFields?”Record<string, unknown>
string
collectionSlug
Section titled “collectionSlug”string
filename
Section titled “filename”string
mimeType
Section titled “mimeType”string
number
storageId
Section titled “storageId”string
Returns
Section titled “Returns”Promise<string>
deleteMedia()
Section titled “deleteMedia()”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.
Type Parameters
Section titled “Type Parameters”TDataModel
Section titled “TDataModel”TDataModel extends GenericDataModel = GenericDataModel
Parameters
Section titled “Parameters”GenericMutationCtx<TDataModel>
collectionSlug
Section titled “collectionSlug”string
mediaId
Section titled “mediaId”string
softDelete?
Section titled “softDelete?”boolean
Returns
Section titled “Returns”Promise<boolean>
getUrl()
Section titled “getUrl()”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.
Type Parameters
Section titled “Type Parameters”TDataModel
Section titled “TDataModel”TDataModel extends GenericDataModel = GenericDataModel
Parameters
Section titled “Parameters”GenericQueryCtx<TDataModel>
collectionSlug
Section titled “collectionSlug”string
mediaId
Section titled “mediaId”string
Returns
Section titled “Returns”Promise<GetUrlReturn>
uploadFile()
Section titled “uploadFile()”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.
Parameters
Section titled “Parameters”any
The file to upload
uploadUrl
Section titled “uploadUrl”string
The presigned URL from generateUploadUrl
Returns
Section titled “Returns”Promise<{[key: string]: unknown; storageId: string; url?: string; }>
Promise resolving to { storageId, url, … } with adapter-specific fields
Example
Section titled “Example”// React componentconst { storageId } = await adapter.uploadFile(file, uploadUrl);await createMediaDocument({ storageId, ... });