Run custom function after upload, but before UI changes

First thank you for the very cool library!

I am currently integrating uppy into an extention for the CMS Joomla!.
During that I came across the need to run a custom function after a file is successfully uploaded, but before the file gets marked as successful in the dashboard.
If my custom function does not return any error the upload should be marked as successful (green thick), but if my custom function do return an error the upload should be marked as failed (red cross).

I tried to use the “upload-success” event but with this event I can not influence the status of the upload and can not influence how it will be shown afterwards in the dashboard.

Is there a way to solve my requirement of this custom function?

Regrads, Manuel

I think found a solution. In the “upload-success” event I am calling my custom function. If this function returns false I call the uppySetFileError() function which I created based on code I found in the core files of uppy:

uppy.on('upload-success', (file, response) => {
    // single uppy upload was successful
    console.log('Upload of '' successful.');

    // custom function
      // Set error if custom function fails
      uppySetFileError('Image manipulation failed...', uppy,, response);

function uppySetFileError(error, uppy, file, response) {
  let errorMsg = error || 'Unknown error';
  let fileID = (typeof file == 'number') ? file :;

  // Add error to global uppy object
  uppy.setState({ error: errorMsg });

  // Add error to specific uppy file
  if (fileID in uppy.getState().files) {
    uppy.setFileState(fileID, {
      error: errorMsg,

Do you think this is a good solution?
Can you think of any side effects of this solution?