StorageAdapterPresignedUrl
Defined in: packages/core/src/media/types.ts:285
Base class for storage adapters.
All file storage adapters must extend this class to ensure consistent behavior in the admin panel. Adapters override methods to implement adapter-specific logic (e.g., different storage backends).
Example
Section titled “Example”// In file-storage-convex/src/adapter/index.tsimport { BaseStorageAdapter } from "@vexcms/core";
export class ConvexStorageAdapter extends BaseStorageAdapter { readonly name = "convex";
async generateUploadUrl(ctx) { const url = await ctx.storage.generateUploadUrl(); return { url }; }
// Override other methods as needed...}Extended by
Section titled “Extended by”Implements
Section titled “Implements”Constructors
Section titled “Constructors”Constructor
Section titled “Constructor”new StorageAdapterPresignedUrl():
StorageAdapterPresignedUrl
Returns
Section titled “Returns”StorageAdapterPresignedUrl
Properties
Section titled “Properties”
abstractadmin:object
Defined in: packages/core/src/media/types.ts:293
softDelete
Section titled “softDelete”softDelete:
boolean
Implementation of
Section titled “Implementation of”StorageAdapterPresignedUrlInterface.admin
mediaCollections
Section titled “mediaCollections”
abstractmediaCollections:MediaCollectionConfig<BaseFieldMeta,MediaCollectionMeta,string,string,ComponentHKT>[]
Defined in: packages/core/src/media/types.ts:291
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.
Implementation of
Section titled “Implementation of”StorageAdapterPresignedUrlInterface.mediaCollections
abstractreadonlyname:string
Defined in: packages/core/src/media/types.ts:287
Protocol name — tells the admin panel what the identifier of this storage adapter is.
Implementation of
Section titled “Implementation of”StorageAdapterPresignedUrlInterface.name
abstractreadonlytype:"presigned-url"
Defined in: packages/core/src/media/types.ts:289
Protocol type — tells the admin panel how to upload files.
Implementation of
Section titled “Implementation of”StorageAdapterPresignedUrlInterface.type
Methods
Section titled “Methods”createMediaDocument()
Section titled “createMediaDocument()”
abstractcreateMediaDocument<TDataModel>(ctx,args):Promise<string>
Defined in: packages/core/src/media/types.ts:307
Creates a media document in Convex after the file is uploaded. Override in subclass for adapter-specific implementation.
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>
Implementation of
Section titled “Implementation of”StorageAdapterPresignedUrlInterface.createMediaDocument
deleteMedia()
Section titled “deleteMedia()”
abstractdeleteMedia<TDataModel>(ctx,args):Promise<boolean>
Defined in: packages/core/src/media/types.ts:324
Deletes a media document and its file from storage. Override in subclass for adapter-specific implementation.
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>
Implementation of
Section titled “Implementation of”StorageAdapterPresignedUrlInterface.deleteMedia
generateUploadUrl()
Section titled “generateUploadUrl()”
abstractgenerateUploadUrl<TDataModel>(ctx):Promise<{storageId?:string;url:string; }>
Defined in: packages/core/src/media/types.ts:299
Generates a URL to upload a file to. Override in subclass for adapter-specific implementation.
Type Parameters
Section titled “Type Parameters”TDataModel
Section titled “TDataModel”TDataModel extends GenericDataModel = GenericDataModel
Parameters
Section titled “Parameters”GenericMutationCtx<TDataModel>
Returns
Section titled “Returns”Promise<{ storageId?: string; url: string; }>
Implementation of
Section titled “Implementation of”StorageAdapterPresignedUrlInterface.generateUploadUrl
getUrl()
Section titled “getUrl()”
abstractgetUrl<TDataModel>(ctx,args):Promise<{error?:undefined;url:string; } | {error:string;url?:undefined; }>
Defined in: packages/core/src/media/types.ts:337
Returns a URL for a media file. Override in subclass for adapter-specific implementation.
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<{ error?: undefined; url: string; } | { error: string; url?: undefined; }>
Implementation of
Section titled “Implementation of”StorageAdapterPresignedUrlInterface.getUrl
uploadFile()
Section titled “uploadFile()”
abstractuploadFile(file,uploadUrl):Promise<{[key:string]:unknown;storageId:string;url?:string; }>
Defined in: packages/core/src/media/types.ts:362
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, ... });