New to Telerik UI for Blazor? Download free 30-day trial

Upload Files to Azure Blob Storage

Environment

Product FileSelect for Blazor,
Upload for Blazor

Description

How to upload files to Microsoft Azure Blob Storage by using Telerik Blazor components?

Can I upload files directly to Azure Blob Storage?

Solution

Both the FileSelect and Upload components can help with uploading files to Azure Blob Storage. There are some differences between how the two components work, which will determine the exact usage.

Using FileSelect

The TelerikFileSelect provides the selected files to the .NET runtime as a System.IO.Stream. Use the OnSelect event to obtain the file and send it to the Azure blob service.

Using Upload

The TelerikUpload needs an HTTP endpoint, which will receive the uploaded file via a POST request.

The Azure Blob Service does not expose such HTTP endpoint. Do the following:

  1. Implement a Save controller action method in the Blazor app.
  2. Set the action method URL as a SaveUrl in the Upload.
  3. Send the uploaded file to the blob service after you obtain it in the Save action method.

In this way, the file will go to your Blazor app server first, then to the Azure storage.

Security

No matter which component you use, we recommend sending the file to the Blazor application server first. This will spare the need to expose sensitive authentication information about the blob storage to the client.

In this article