I'm trying to upload a file using Blazor server-side.
The file needs to be saved in an Azure blobcontainer but before that some some checks need to be performed to prevent overwritten an existing file and after saved to the blob a record in a table needs to be added.
Also a desktop application should be able to upload a file.
So I think I need a controller to do this. I've used similar with a .NET Framework v4.6 web app.
I'm having trouble understanding how to send the file to my controller. Do I need to read the file first into memory? I hope not because the files can be very large (up to 500MB).
I'm looking at the SingleFile demo:
async Task HandleSelection(IFileListEntry[] files)
{
var file = files.FirstOrDefault();
if (file != null)
{
I assume I need to call await HttpClient.PostAsync("/api/upload/files", content) but how to go from file to content?
I'm trying to upload a file using Blazor server-side. The file needs to be saved in an Azure blobcontainer but before that some some checks need to be performed to prevent overwritten an existing file and after saved to the blob a record in a table needs to be added. Also a desktop application should be able to upload a file.
So I think I need a controller to do this. I've used similar with a .NET Framework v4.6 web app.
I'm having trouble understanding how to send the file to my controller. Do I need to read the file first into memory? I hope not because the files can be very large (up to 500MB).
I'm looking at the SingleFile demo:
I assume I need to call
await HttpClient.PostAsync("/api/upload/files", content)
but how to go fromfile
tocontent
?Or should I use a different approach?