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
I also tried declaring and exporting deleteFiles explicitly in server actions and calling it but it threw error like
I have referred the official docs but couldn't infer how to delete files
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 functionI 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 valueI have referred the official docs but couldn't infer how to delete files
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!
I wanted to use Next.js because I thought I wouldn't have to make fetch calls to an internal API!
GitHub
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...