angular 5

Story of File Uploading in ASP.NET Core (Part III - Streaming Files)

We must consider saving files in byte[] formats unless it is absolute necessary, because over the time it can affect the performance of any data storage system. With that being said, streaming can be a good idea in this scenario. We can configure a static files folder for storing the uploaded files. However, this part is optional. You can simply use the web root folder wwwroot instead. But let's just see how to create a separate static files folder on the content root and use it to serve the uploaded…

Keep reading

Story of File Uploading in ASP.NET Core (Part II - Angular/AJAX)

Uploading files from Angular end to an ASP.NET Core Web API can be done using the same IFormFile interface; introduced in the previous post. To keep things separated, a new API controller (UserController) has been created with the following POST action, [HttpPost] public async Task<IActionResult> PostUser([FromForm]UserVM vm) { if (!ModelState.IsValid) { return BadRequest(ModelState); } /* Use Automapper for mapping UserVM to User */ User user = new User { Name = vm.Name }; using (var memoryStream = new MemoryStream()) { await vm.Avatar.CopyToAsync(memoryStream); user.Avatar = memoryStream.ToArray(); } _context.Users.Add(…

Keep reading

Angular Forms Validation, updateOn: 'blur' & updateOn: 'submit' (Angular 5 edition)

In my previous post, I wrote about Asynchronous Validation in Angular's Reactive Forms Control. But that was when we were in the age of Angular 4, now a new age is upon us: age of Angular 5. With the new version, we have some new ways of doing validations in Angular forms. Since I won’t talk about everything from the beginning (How to define a form model, how to add validators etc.), consider this post as a continuation of my previous one. I’ll just show you the two…

Keep reading