xewn
xewn
TTCTheo's Typesafe Cult
Created by xewn on 6/23/2024 in #questions
How to send additional information with a file using UploadThing?
Hey everyone! I have had a great time implementing upload thing into my application using the docs and would love to profit from the simplicity of using the inbuilt frontend components aswell! To properly authorize the usage and categorize the file in the database, I need to send additional information about the files context to the authorization middle ware including ids of objects that the files belong to, unfortunatly I havent seen any simple way to do this using the generated components... Has anyone had that problem before? The behaviour I would like (for example):
<UploadButton /> --> /api/uploadthing?objectId=123 --> .middleware((req) => ... req.nextUrl.searchParams.get("objectId"))
<UploadButton /> --> /api/uploadthing?objectId=123 --> .middleware((req) => ... req.nextUrl.searchParams.get("objectId"))
Or even better would be
<UploadButton someCustomContent={content} /> --> /api/uploadthing --> .middleware((req, content) => ... content.objectId)
<UploadButton someCustomContent={content} /> --> /api/uploadthing --> .middleware((req, content) => ... content.objectId)
2 replies