I'am rewriting a .net 4.5 application to aspnet core 2.0 and I have a method that i have some problem updating:
[HttpPut]
[Route("api/files/{id}")]
public async Task<Person> Put(int id)
{
var filesReadToProvider = await Request.Content.ReadAsMultipartAsync();
var fileStream = await filesReadToProvider.Contents[0].ReadAsStreamAsync();
return _personService.UpdatePerson(id, fileStream);
}
It seems that request no longer has Content, but body. Which is fine. But how how do i read the body if it is a MimeMultipart now?
I have looked into IFormFile, but don't I have to change something in the frontend?
Anything that will help me in the right direction is appreciated :)
. NET Core 2.2 was released on December 4, 2018. As a non-LTS (“Current”) release, it is supported for three months after the next release. .
Net 5 that is Opensource and Cross-platform, which will replace . Net Framework, . Net Core and Xamarin with a single unified platform called . Net 5 Framework.
NET is platform dependent, Mono allows developers to build Linux and cross- platform applications. Mono's . NET implementation is based on the ECMA standards for C#. This paper examines both of these programming environments with the goal of evaluating the performance characteristics of each.
. NET Core 3.1 is also known for Blazor, the ASP.NET Core technology that puts WebAssembly to use as a browser compilation target for higher-order programming languages so they can be used in Web development instead of JavaScript.
See File uploads in ASP.NET Core ... mainly the section of Uploading large files with streaming. It has to be something like
var boundary = MultipartRequestHelper.GetBoundary(
MediaTypeHeaderValue.Parse(Request.ContentType),
_defaultFormOptions.MultipartBoundaryLengthLimit);
var reader = new MultipartReader(boundary, HttpContext.Request.Body);
var section = await reader.ReadNextSectionAsync();
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With