filestack / filestack-js

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

Errors not visible in picker during onFileSelected callback #382

Open dylanfisher opened 4 years ago

dylanfisher commented 4 years ago

https://www.filestack.com/docs/concepts/pickers/web/#callbacks

I followed the example in the callbacks section of your docs regarding throwing an error if a file is larger than a certain size, but this error isn't visible. Is this a bug in the filestack code? If I call a default alert() before throwing the error I can still indicate to the user that there was a problem, but it would be nice if this was displayed in the picker itself.

const client = filestack.init(apiKey);
const maxSizeMegabytes = 10;
const options = {
  fromSources: ["local_file_system"],
  accept: [".pdf"],
  onFileSelected: file => {
    // If you throw any error in this function it will reject the file selection.
    // The error message will be displayed to the user as an alert.
    if ( file.size > 1000 * 1000 * maxSizeMegabytes ) {
      throw new Error(`File too big, select something smaller than ${maxSizeMegabytes}MB`);
    }
  }
};
opizzato commented 3 years ago

This seems to be the same issue as issue 335

stephkoltun commented 3 years ago

@dylanfisher the css fix suggested in #335 ended up fixing it for me.