How to delete files in UploadThing?
I am using NextJS
I can't get the deleteFiles function to work for uploadthing
What I have tried,
created a uploadthing.js file in ~/server
I tried to call utapi.deleteFiles() but Webpack threw an error
TypeError: _server_uploadthing__WEBPACK_IMPORTED_MODULE_3__.utapi.deleteFiles is not a function
I also tried declaring and exporting deleteFiles explicitly in server actions and calling it but it threw error like
Error deleting files: Error: inArray requires at least one value
I have referred the official docs but couldn't infer how to delete filesSolution:Jump to solution
This seems to be the clunky way to fix it: https://github.com/pingdotgg/uploadthing/issues/213
I wanted to use Next.js because I thought I wouldn't have to make fetch calls to an internal API!...
GitHub
[BUG]: getting error on using utapi.deleteFiles · Issue #213 · ping...
hey, im getting "Missing UPLOADTHING_SECRET env variable." when trying to delete file. this is my code : export const deleteFiles = async (fileKey: string) => { await utapi.deleteFiles...
5 Replies
update: tried creating delete function in server/uploadthing.js but now i get the following error
I am passing the file keys as mentioned in https://discord.com/channels/966627436387266600/1169240516546789386/1181741963557478470
but still get the error
I'm having the same problem as your first post, except I'm still on Next.js 13.5.3.
I also tried adding
uploadthing/server
to my serverComponentsExternalPackages
in Next config. But that didn't fix it.Solution
This seems to be the clunky way to fix it: https://github.com/pingdotgg/uploadthing/issues/213
I wanted to use Next.js because I thought I wouldn't have to make fetch calls to an internal API!
GitHub
[BUG]: getting error on using utapi.deleteFiles · Issue #213 · ping...
hey, im getting "Missing UPLOADTHING_SECRET env variable." when trying to delete file. this is my code : export const deleteFiles = async (fileKey: string) => { await utapi.deleteFiles...
Thanks man, I hope they update the documentation and push a fix soon