Remove file uploader message automatically

When the file size is bigger than the specified size, the following message appears.
image

How can I make it disappear automatically within a certain time like we do as follows?

 notifications.create("Sorry, the event date of this leave type can not be in the future")
                                            .withType(Notifications.Type.WARNING)
                                            .withDuration(5000)
                                            .withCloseable(false)
                                            .withPosition(Notification.Position.MIDDLE)
                                            .show();

Hi

Don’t show the upload button if not all conditions are true and display instead whatever you wish

Regards
Felix

Hello,

This message is displayed by default if an error message listener of the FileUploadFileRejectedEvent type is not installed for the component.

Therefore, you only need to add the following code in the view:

fileStorageUploadField.addFileUploadFileRejectedListener(event -> notifications.create(event.getErrorMessage())
                                            .withType(Notifications.Type.WARNING)
                                            .withDuration(5000)
                                            .withCloseable(false)
                                            .withPosition(Notification.Position.MIDDLE)
                                            .show());

Thanks,
Ilya