filestack / filestack-js

Official Javascript SDK for the Filestack API and content ingestion system.
https://www.filestack.com
MIT License
206 stars 76 forks source link

onFileUploadCancel breaks with url sources #456

Open lmeirelesfull opened 3 years ago

lmeirelesfull commented 3 years ago

Expected Behavior

I would like to be able to use the onFileUploadCancel with 'url' type sources and be able to validate the link properly displaying an error message on invalid links.

Current Behavior

Right now if I add the onFileUploadCancel callback to my options and use an invalid url on the url field the plugin crashes instead of showing the correct validation message to the user.

Possible Solution

Probably a validation on the file object before calling the onFileUploadCancel

Steps to Reproduce (for bugs)

Just enter the jsFiddle and configure with a valid API_KEY then use an invalid image link like https://www.google.com

https://jsfiddle.net/aLrfe7z0/

If you want to reproduce the bug locally instead just:

  1. Setup filestack-js and make sure it accepts 'url' (fromSources: ["url"]) on the options.
  2. Adds a onFileUploadCancel to the options:
    onFileUploadCancel: () => {
    console.log('test');
    },
  3. Now try to use an invalid image link like https://google.com

Additional Screenshots

Screen Shot 2021-08-11 at 6 15 14 PM

Your Environment