Skip to content

ConvexStorageAdapter

Defined in: packages/file-storage-convex/src/adapter/index.ts:32

Convex storage adapter class — extends BaseStorageAdapter.

All adapter methods accept the Convex ctx as the first parameter, allowing access to ctx.db, ctx.storage, and other context methods.

apps/test/app/admin/layout.tsx
import { ConvexStorageAdapter } from "@vexcms/file-storage-convex/adapter";
const adapter = new ConvexStorageAdapter({ mediaCollections: [images] });
return <AdminPanel adapterClient={adapter}>{children}</AdminPanel>;

new ConvexStorageAdapter(options): ConvexStorageAdapter

Defined in: packages/file-storage-convex/src/adapter/index.ts:43

Creates a new ConvexStorageAdapter instance.

ConvexFileStorageOptions

Adapter configuration including media collections and soft-delete behaviour.

ConvexStorageAdapter

StorageAdapterPresignedUrl.constructor

admin: object

Defined in: packages/file-storage-convex/src/adapter/index.ts:36

softDelete: boolean = false

StorageAdapterPresignedUrl.admin


readonly mediaCollections: MediaCollectionConfig[]

Defined in: packages/file-storage-convex/src/adapter/index.ts:35

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.

StorageAdapterPresignedUrl.mediaCollections


readonly name: "convex" = "convex"

Defined in: packages/file-storage-convex/src/adapter/index.ts:33

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

StorageAdapterPresignedUrl.name


readonly type: "presigned-url" = STORAGE_ADAPTER_PROTOCOLS.presignedUrl

Defined in: packages/file-storage-convex/src/adapter/index.ts:34

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

StorageAdapterPresignedUrl.type

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

Defined in: packages/file-storage-convex/src/adapter/index.ts:74

Inserts a media document into the target collection table after a file upload completes.

TDataModel extends GenericDataModel = GenericDataModel

GenericMutationCtx<TDataModel>

Convex mutation context.

Document fields: collectionSlug, storageId, filename, mimeType, size, optional alt and adapterFields.

Record<string, unknown>

string

string

string

string

number

string

Promise<string>

Promise resolving to the new media document ID as a string.

StorageAdapterPresignedUrl.createMediaDocument


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

Defined in: packages/file-storage-convex/src/adapter/index.ts:98

Deletes a media document — physically removes the file from Convex storage unless softDelete (or this.admin.softDelete) is true, in which case the document is patched with { deleted: true }.

TDataModel extends GenericDataModel = GenericDataModel

GenericMutationCtx<TDataModel>

Convex mutation context.

collectionSlug, mediaId, and optional softDelete override.

string

string

boolean

Promise<boolean>

Promise resolving to true if the document was found and processed.

StorageAdapterPresignedUrl.deleteMedia


generateUploadUrl<TDataModel>(ctx): Promise<GenerateUploadUrlReturn>

Defined in: packages/file-storage-convex/src/adapter/index.ts:61

Generates a presigned upload URL via ctx.storage.generateUploadUrl().

TDataModel extends GenericDataModel = GenericDataModel

GenericMutationCtx<TDataModel>

Convex mutation context.

Promise<GenerateUploadUrlReturn>

Promise resolving to { url: string } — POST the file body to this URL.

StorageAdapterPresignedUrl.generateUploadUrl


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

Defined in: packages/file-storage-convex/src/adapter/index.ts:120

Resolves a serving URL for a media document by looking up its storageId and calling ctx.storage.getUrl().

TDataModel extends GenericDataModel = GenericDataModel

GenericQueryCtx<TDataModel>

Convex query context.

collectionSlug and mediaId of the target media document.

string

string

Promise<GetUrlReturn>

Promise resolving to { url } on success or { error } if the document or file is not found.

StorageAdapterPresignedUrl.getUrl


uploadFile(file, uploadUrl): Promise<UploadFileReturn>

Defined in: packages/file-storage-convex/src/adapter/index.ts:139

POSTs a file to the presigned upload URL returned by generateUploadUrl.

Runs in the browser — no Convex context required.

File

The File object to upload.

string

Presigned URL from generateUploadUrl.

Promise<UploadFileReturn>

Promise resolving to { storageId } assigned by Convex storage.

StorageAdapterPresignedUrl.uploadFile