File Input upload error handling


Topic: File Input upload error handling

kepner pro premium priority asked 5 years ago

**Expected behavior**

It should return the error message of the failed Upload Http call

**Actual behavior**

I can't find a way to handle the error callback.

**Usecase**

I have implemented my own backend to be able to handle the file upload. It works good but when I try to validate either the File size or the File Type(again) and I return an Error 400 Bad Request response with some message I'm not able to catch it on the frontend. I tried to figure out where the xhr call will be fired from the mdb file input module but I was not able to find it. Can you please help me how to handle the callback errors, or where can I find the xhr call?

Thank you very much.


Arkadiusz Idzikowski staff answered 5 years ago

You can add something like this to the onUploadOutput method:

  } else if (output.type === 'done') {
    if (output.file.responseStatus === 400) {
      console.log(output.file.response);
      // do something
    }
  }

kepner pro premium priority commented 5 years ago

Thank you very much for the fast response! :)


Please insert min. 20 characters.

FREE CONSULTATION

Hire our experts to build a dedicated project. We'll analyze your business requirements, for free.

Status

Resolved

Specification of the issue
  • User: Pro
  • Premium support: Yes
  • Technology: MDB Angular
  • MDB Version: 8.4.0
  • Device: Desktop
  • Browser: Chrome 78.0.3904.70 64bit
  • OS: Windows10 Prof 64bit
  • Provided sample code: No
  • Provided link: No