Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

@vercel/blob - Make onUploadCompleted optional #721

Open
joaopedrocn opened this issue Jul 7, 2024 · 2 comments
Open

@vercel/blob - Make onUploadCompleted optional #721

joaopedrocn opened this issue Jul 7, 2024 · 2 comments

Comments

@joaopedrocn
Copy link

According to the documentation, the responsibility of the client upload route is to:

  1. Generate tokens for client uploads
  2. 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.

@joaopedrocn joaopedrocn changed the title @vercel/blob - Support for not using onUploadCompleted @vercel/blob - Make onUploadCompleted optional Jul 7, 2024
@vvo
Copy link
Member

vvo commented Jul 23, 2024

@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!

@joaopedrocn
Copy link
Author

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants