Upload large files in Blazor FileManager Component

10 Jun 20241 minute to read

To enable large file uploads in the Blazor FileManager component, you can set the MaxFileSize property in the FileManagerUploadSettings class. This property allows you to specify the maximum file size that can be uploaded, in bytes.

Here’s an example of how to set the MaxFileSize property to allow uploads of large files:

<SfFileManager @ref="FileManager" TValue="FileManagerDirectoryContent">
    <FileManagerAjaxSettings Url="https://ej2-aspcore-service.azurewebsites.net/api/FileManager/FileOperations"
                                UploadUrl="https://ej2-aspcore-service.azurewebsites.net/api/FileManager/Upload"
                                DownloadUrl="https://ej2-aspcore-service.azurewebsites.net/api/FileManager/Download"
                                GetImageUrl="https://ej2-aspcore-service.azurewebsites.net/api/FileManager/GetImage">
    </FileManagerAjaxSettings>
    <FileManagerUploadSettings MaxFileSize="30000000"></FileManagerUploadSettings>
    <FileManagerEvents></FileManagerEvents>
</SfFileManager>

Server configuration for large files upload

To handle large file uploads on the server side, you can also configure the file size in the server’s web.config file. Here’s an example of how to set the maximum file size in the web.config file:

<configuration>
  <system.webServer>
    <security> 
      <requestFiltering> 
        <requestLimits maxAllowedContentLength="1073741824" ></requestLimits> 
      </requestFiltering> 
    </security> 
  </system.webServer>
</configuration>

NOTE

The above-mentioned configuration is only applicable for running a separate service, as well as when your Blazor Sample with Service is the same application running on IIS Express.