As @Kornelis mentioned you can use BlazorFileReader to get the byte stream of a file. I'm using the lib. in a similar way to upload files. I just don't upload to the server, instead I'm creating sas token for a blob in Azure Blob Storage and use the storage REST API to upload the file data.
To load the file from an input html element:
<input type="file" @ref="@inputTypeFileElement" @ref:suppressField />
Note: currently in prev8 there is a know bug using @ref for this cases. That way the @ref:suppressField is needed.
For getting the file stream with the library:
foreach (var file in await fileReaderService.CreateReference(inputTypeFileElement).EnumerateFilesAsync()) { using (Stream stream = await file.OpenReadAsync()) { await viewModel.UploadAsync(stream); } }
And here is how I process the stream:
public async Task UploadAsync(Stream stream) { using (HttpContent fileStreamContent = new StreamContent(stream)) { //Add any headers you require here fileStreamContent.Headers.Add("x-ms-blob-type", "BlockBlob"); var response = await _httpClient.PutAsync("your upload endpoint url", fileStreamContent); } }