Skip to content

Uploading Files

As of 1.11.0, Wolverine supports file uploads through the standard ASP.Net Core IFile or IFileCollection types. All you need to do to is to have an input parameter to your Wolverine.HTTP endpoint of these types like so:

cs
public class FileUploadEndpoint
{
    // If you have exactly one file upload, take
    // in IFormFile
    [WolverinePost("/upload/file")]
    public static Task Upload(IFormFile file)
    {
        // access the file data
        return Task.CompletedTask;
    }

    // If you have multiple files at one time,
    // use IFormCollection
    [WolverinePost("/upload/files")]
    public static Task Upload(IFormFileCollection files)
    {
        // access files
        return Task.CompletedTask;
    }
}

snippet source | anchor

See Upload files in ASP.NET Core for more information about these types.

Released under the MIT License.