You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
According to the documentation, the responsibility of the client upload route is to:
Generate tokens for client uploads
Listen for completed client uploads, so you can update your database with the URL of the uploaded file for example
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.
The text was updated successfully, but these errors were encountered:
joaopedrocn
changed the title
@vercel/blob - Support for not using onUploadCompleted
@vercel/blob - Make onUploadCompleted optional
Jul 7, 2024
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!
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.
The text was updated successfully, but these errors were encountered: