

But when it comes to files, any sort of model binding will try to…you guessed it, read the entire file into memory. MVC is very good at model binding from the web request. Which is exactly what we don’t want to do with large files. If you let MVC try to bind to an IFormFile, it will attempt to spool the entire file into memory. Handling large file uploads is complex and before tackling it, you should see if you can offload that functionality to Azure Blob Storage entirely. You may be able to use client-side direct uploads if your architecture supports generating SAS (Shared Access Signature) upload Uris, and if you don’t need to process the upload through your API.

NET MVC for uploading large files to Azure Blob Storage DON’T do it if you don’t have to For larger file size situations, we need to be much more careful about how we process the file. These are fine for small files, but I wouldn’t recommend them for file sizes over 2MB. You’ll find a lot of file upload examples out there that use what I call the “small file” methods, such as IFormFile, or using a byte array, a memory stream buffer, etc. But if you want to let your users upload large files you will almost certainly want to do it using streams. With Azure Blob Storage, there multiple different ways to implement file uploads. Implement file uploads in the wrong way, and you may end up with memory leaks, server slowdowns, out-of-memory errors, and worst of all unhappy users. What’s the big deal about file uploads? Well, the big deal is that it is a tricky operation.
