Using UploadThing as Storage in Payload CMS errors on Vercel

I am trying to use UploadThing as my storage option working with Payload CMS. I am using their recommended adapter: https://www.npmjs.com/package/@payloadcms/storage-uploadthing My collection has no custom upload prop definitions. Locally everything works fine, but when being deployed to Vercel, when uploading a file, it tries executing mkdir /vercel on the server which errors of course due to the serverless architecture and the read-only behaviour inside of it. I tried overriding it by setting
upload: {
// /tmp is the only writable directory in a Vercel environment
tempFileDir: '/tmp',
},
upload: {
// /tmp is the only writable directory in a Vercel environment
tempFileDir: '/tmp',
},
but that didn't change anything. Did anyone else using Payload experienced similar behaviour? I am not sure if this is an issue with Uploadthing itself or with the Payload adapter. I couldn't find anything useful in the dependencies' source code that would explain the hardcoded path. Hints for possible issues are greatly appreciated 🙏
npm
@payloadcms/storage-uploadthing
Payload storage adapter for uploadthing. Latest version: 3.54.0, last published: 3 days ago. Start using @payloadcms/storage-uploadthing in your project by running npm i @payloadcms/storage-uploadthing. There are 0 other projects in the npm registry using @payloadcms/storage-uploadthing.
1 Reply
Froxx
FroxxOP3mo ago
Welp, nevermind. Seems like the target dir /vercel actually gets updated by defining upload.tempFileDir in the payload.config file, and I just tested in the wrong environment ✨ Taking a break and having a clear head the next day never fails to amaze me

Did you find this page helpful?