ASP.NET Core 2.0 and Angular 4.3 File Upload with progress

前端 未结 2 1477
温柔的废话
温柔的废话 2020-12-25 10:23

Using the new Angular 4.3 HttpClient, how can I upload and access files in an ASP.NET Core 2.0 Controller while reporting upload progress to the client?

2条回答
  •  独厮守ぢ
    2020-12-25 10:56

    You could use the interface Microsoft.AspNetCore.Http.IFormFile that represents a file sent with the HttpRequest to simplify the access to file.

    [HttpPost, DisableRequestSizeLimit, Route("api/files")]
    public async Task UploadFiles(IFormFile file){
        //your file stream
        var stream = file.OpenReadStream();
    }
    

提交回复
热议问题