When uploading file via client side upload we invalidate it then on the server side with re-uploading. This works fine with most adapters since they just replace the old file under the same key. UploadThing works differently and generates a new key every time. Example of the issue: <img width="611" alt="image" src="https://github.com/user-attachments/assets/9c01b52a-d159-4f32-9f66-3b5fbadab7b4" /> Now, we clear the old file before doing re-upload.
Uploadthing Storage for Payload (beta)
This package provides a way to use uploadthing with Payload.
Installation
pnpm add @payloadcms/storage-uploadthing
Usage
- Configure the
collectionsobject to specify which collections should use uploadthing. The slug must match one of your existing collection slugs and be anuploadtype. - Get an API key from Uploadthing and set it as
apiKeyin theoptionsobject. aclis optional and defaults topublic-read.- When deploying to Vercel, server uploads are limited with 4.5MB. Set
clientUploadstotrueto do uploads directly on the client.
export default buildConfig({
collections: [Media],
plugins: [
uploadthingStorage({
collections: {
media: true,
},
options: {
token: process.env.UPLOADTHING_TOKEN,
acl: 'public-read',
},
}),
],
})