import type { AdminStorageProvider, AdminStorageUploadInput } from '@admin/actions/storage/types' import { buildStorageObjectKey } from '@admin/actions/storage/object-key' import { getToken } from '@admin/actions/vercel-blob/get-token' import { put } from '@vercel/blob' export const vercelBlobStorageProvider: AdminStorageProvider = { id: 'vercel-blob', isConfigured() { return Boolean(getToken()) }, async saveFile(input: AdminStorageUploadInput) { if (!this.isConfigured()) { throw new Error('Vercel Blob is not configured.') } const key = buildStorageObjectKey(input.filename, input.prefix) const blob = await put(key, input.buffer, { access: 'public', contentType: input.contentType, token: getToken() }) return { key, url: blob.url } } }