import type { CollectionConfig } from 'payload'
export const Media: CollectionConfig = { slug: 'media', access: { read: () => true, }, fields: [ { name: 'alt', type: 'text', required: false, }, ], upload: true, }
// storage-adapter-import-placeholder import { mongooseAdapter } from '@payloadcms/db-mongodb' import { payloadCloudPlugin } from '@payloadcms/payload-cloud' import path from 'path' import { buildConfig } from 'payload' import sharp from 'sharp' import { fileURLToPath } from 'url'
import { Listings } from './collections/Listings' import { Localities } from './collections/Localities' import { Media } from './collections/Media' import { Teams } from './collections/Teams' import { Users } from './collections/Users' import { defaultLexical } from './components/defaultLexical'
// import { firebaseAdapter } from '@payloadcms/storage-firebase' // import firebaseAdmin from 'firebase-admin'
const filename = fileURLToPath(import.meta.url) const dirname = path.dirname(filename)
// Initialize Firebase Admin with your service account credentials // const serviceAccount = JSON.parse(process.env.FIREBASE_SERVICE_ACCOUNT_KEY || '{}')
// firebaseAdmin.initializeApp({ // credential: firebaseAdmin.credential.cert(serviceAccount), // storageBucket: process.env.FIREBASE_STORAGE_BUCKET, // })
// // Create Firebase Storage adapter // const firebaseStorage = firebaseAdapter({ // bucket: firebaseAdmin.storage().bucket(), // prefix: 'media', // Optional prefix for storage bucket // })
// // Modify Media collection to use Firebase Storage // const MediaWithFirebase: CollectionConfig = { // ...Media, // upload: { // adapter: firebaseStorage, // disableLocalStorage: true, // Disable local file storage // }, // }
export default buildConfig({ admin: { user: Users.slug, importMap: { baseDir: path.resolve(dirname), }, }, collections: [Users, Media, Listings, Localities, Teams], editor: defaultLexical, secret: process.env.PAYLOAD_SECRET || '', typescript: { outputFile: path.resolve(dirname, 'payload-types.ts'), }, db: mongooseAdapter({ url: process.env.DATABASE_URI || '', }),
sharp, plugins: [ payloadCloudPlugin(), // storage-adapter-placeholder ], })
using vercel blob storage that store the image and return the url to store to database how do i do this integration
This integration provides several benefits:
Note that Vercel Blob storage currently doesn't support direct file deletion through the API. File management should be done through the Vercel Dashboard. If you need programmatic deletion, you might want to implement a cleanup process using Vercel's CLI or wait for API deletion support to be added.
Cannot find module 'payload/dist/uploads/types' or its corresponding type declarations.
and use typescript
then optimize the image if more upto 10mb