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

There is no onError props or a way to check if the upload didn't work #361

Open
jonnigs opened this issue Nov 24, 2022 · 2 comments
Open

Comments

@jonnigs
Copy link

jonnigs commented Nov 24, 2022

Brief description of the feature and motivation behind it

I'm using a custom button that opens up the Uploadcare widget. Once the file is selected, the widget is closed and a loading state is displayed (and form submission is disabled) until the onChange function fires and the selected file name is displayed in the button. Now it has happened two days in a row that the file upload does not succeed and the onChange function does not fire, leaving me with a hanging loading state.

Can the onChange function fire with error props? Or is it possible to add onError props to the widget so that I can react accordingly and display that an error occured?

Some way to check if the upload does not succeed. This could be a new props or addition to the onChange.

I think error handling is important.
Some users don't want to use the widget button that comes with the package.

@optlsnd
Copy link

optlsnd commented Nov 24, 2022

Hi @jonnigs , you can handle upload errors this way:

<Widget
  onDialogOpen={(dialog) => {
    dialog.fileColl.onAdd.add((file) => {
      file.fail((errorType, fileInfo, error) => {
        console.error(errorType, error);
      });
    });
  }}
/>

This will work with both single and multiple uploads. More info about the file.fail method can be found here. Dialog and File Collection methods are covered in this docs article.

@jonnigs
Copy link
Author

jonnigs commented Nov 25, 2022

Thank you for this! I completely missed this in the docs.

I think the issue/feature request still holds, onError prop in the widget would be nice and easier to work with.

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

No branches or pull requests

2 participants