microsoft / fluentui-blazor

Microsoft Fluent UI Blazor components library. For use with ASP.NET Core Blazor applications
https://www.fluentui-blazor.net
MIT License
3.23k stars 294 forks source link

feat: display error when MaximumFileSize is exceeded #1975

Closed verdie-g closed 2 weeks ago

verdie-g commented 2 weeks ago

I would like to display an error when a file greater than MaximumFileSize is fed to an InputFile. I believe that would be the role of OnFileError but its comment mentions

Raise when a file raised an error. Not yet used.

which I suppose means it is not available yet. Could you consider implementing it 🙏

dvoituron commented 2 weeks ago

Indeed, this OnFileError attribute is not yet implemented and usable in the component. However, you can obtain this "size too large" information in the ErrorMessage property of transferred files. In the example on the demo page:

<li>
  <b>@file.Name</b>
  @($"{Decimal.Divide(file.Size, 1024):N} KB")
  @file.ContentType
  @file.LocalFile?.FullName
  @file.ErrorMessage   <!-- This property will contain "The maximum size allowed is reached" -->
</li>