Skip to content
This repository was archived by the owner on May 5, 2021. It is now read-only.
This repository was archived by the owner on May 5, 2021. It is now read-only.

How to send the file to MVC controller #60

@pmeems

Description

@pmeems

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?

Or should I use a different approach?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions