[SalesForce] lightning:fileupload – Override default error message when unacceptable file format is uploaded

I am using lightning:fileupload in my lightning page. It works fine, but I am unable to override the default error message displayed (your company does not allow the file format…etc). Business wants a custom message to be displayed, not this default one. I tried to use toast message, but that is in addition to the default message.

Any one has any ideas on how to override the default message?

Thanks in advance.
Vardi.

Best Answer

Not sure you can override the standard message "your company does not allow the file format..".

This message is displayed if the file type uploaded is not within the list accept attribute. I believe you have such an accept attribute similar to this in your component markup:

<aura:attribute name="accept" type="List" default="['.jpg', '.jpeg']"/>

If the list of file types triggered by the standard message is known, then a possible workaround is to include these in the list of accept attribute so that the standard message does not get fired.

But then add custom logic in handleUploadFinished to validate the file type in your component JS to invoke your custom toast with custom message.

Related Topic