Open joaopedrocn opened 4 months ago
@joaopedrocn thanks for opening this.
I want to handle the database update with a server action though
Can you provide us with more details as to what/how you're trying to accomplish? So we get a better understanding about why you do not need the onUploadCompleted. Thanks!
Hey, thanks for the reply.
So in my application there is a form where users (nutritionists) can upload supporting materials for their patients. This form has many inputs besides the file one (name, description, etc.). When the user selects a file through the file input, I want to upload this file to Vercel Blob right away, and only when the user submits the form with all required fields, persist everything in the database with a server action.
So in this case the onUploadCompleted is useless, because I don't want to do anything after the file is uploaded (I just need the blob url).
Shopify does something similar. In the create/edit a product page you can upload images, which will be stored right away, even if you don't end up creating/saving the product.
According to the documentation, the responsibility of the client upload route is to:
I want to handle the database update with a server action though, so I just need the first part. However, typescript complains if I don't provide an onUploadCompleted callback. My suggestion is to make this callback optional, and do not send webhooks in that case.