Search code examples
sapui5

SAPUI5 FileUploader Maximum File Size Alert


When using the standard SAPUI5 FileUploader , is it possible to display a notification when the maximumFileSize property is exceeded?

As I see it, the uploader simply won't accept the file if the limit is exceded.

Thanks for your help!

Example

<FileUploader
    maximumFileSize="{Config>/maximumFileSize}"
    uploadComplete="onAttachmentUploadComplete">
    ....
</FileUploader>

Solution

  • Uploader in your view:

      <FileUploader
           maximumFileSize="{Config>/maximumFileSize}"
           uploadComplete="onAttachmentUploadComplete"
           fileSizeExceed="onFileSizeExceed">
      </FileUploader>
    

    Method in your corresponding controller:

    onFileSizeExceed: function(error) {
        console.log(error)
    }
    

    I think it is up to you to read the error message and show it in a message toast for example.