Files
payload/test/storage-uploadthing/config.ts
Elliot DeNolf 4690cd819a feat(storage-uploadthing)!: upgrade to v7 (#8346)
Upgrade uploadthing to v7

The `options` that can be passed to the plugin now mirror the
`UTApiOptions` of v7.

The most notable change is to pass `token` with
`process.env.UPLOADTHING_TOKEN` instead of `apiKey` with
`process.env.UPLOADTHING_SECRET`.

```diff
options: {
- apiKey: process.env.UPLOADTHING_SECRET,
+ token: process.env.UPLOADTHING_TOKEN,
  acl: 'public-read',
},
2024-11-13 21:27:02 +00:00

52 lines
1.3 KiB
TypeScript

import { uploadthingStorage } from '@payloadcms/storage-uploadthing'
import dotenv from 'dotenv'
import { fileURLToPath } from 'node:url'
import path from 'path'
import { buildConfigWithDefaults } from '../buildConfigWithDefaults.js'
import { devUser } from '../credentials.js'
import { Media } from './collections/Media.js'
import { MediaWithPrefix } from './collections/MediaWithPrefix.js'
import { Users } from './collections/Users.js'
import { mediaSlug } from './shared.js'
const filename = fileURLToPath(import.meta.url)
const dirname = path.dirname(filename)
// Load test env creds
dotenv.config({
path: path.resolve(dirname, './.env'),
})
export default buildConfigWithDefaults({
admin: {
importMap: {
baseDir: path.resolve(dirname),
},
},
collections: [Media, MediaWithPrefix, Users],
onInit: async (payload) => {
await payload.create({
collection: 'users',
data: {
email: devUser.email,
password: devUser.password,
},
})
},
plugins: [
uploadthingStorage({
collections: {
[mediaSlug]: true,
},
options: {
token: process.env.UPLOADTHING_TOKEN,
acl: 'public-read',
},
}),
],
typescript: {
outputFile: path.resolve(dirname, 'payload-types.ts'),
},
})