What is the (best) flow for using UploadThing inside my react hook form?

When the form is submitted, I would like to create a record in the database with the associated files added by the form.

Question 1: Does it make sense to have an extra table in the database called files with the fields: id, key, url, name, size so I can link multiple files to other records with many to one/many relationships.

Question 2: What is the correct order for my use case? For example, should I upload the files first and then set the file keys as form values or is there a better way?

Thank you in advance!
Schermafbeelding_2023-10-05_om_15.56.53.png
Was this page helpful?