pingdotgg / uploadthing

File uploads for modern web devs
https://uploadthing.com
MIT License
4.13k stars 305 forks source link

feat: expose `waitUntil` for Next.js adapter #797

Open juliusmarminge opened 4 months ago

juliusmarminge commented 4 months ago

Describe the feature you'd like to request

https://vercel.com/docs/functions/functions-api-reference#waituntil

I think it’d be useful to have this exposed in the onUploadComplete callback, since you could do some stuff non-blocking (such as delete an old image for example) without blocking server polling response times

Describe the solution you'd like to see

.onUploadComplete(async ({ file, metadata, ctx }) => {
  await db.update(...)
  // delete old file non-blocking
  ctx.waitUntil(() => {
    utapi.deleteFile(metadata.oldFileKey)
  })
})

Additional information

No response

πŸ‘¨β€πŸ‘§β€πŸ‘¦ Contributing

r0ld3x commented 3 weeks ago

I can work in this