Operation of Request.Files;

2

I have an Asp .Net MVC project, with a form in View that sends files to the Controller .

In control I retrieve the files as follows:

var myFiles = Request.Files;

I do not save the file, I just read the contents.

The question is: Where are these Request.Files files? In memory or in some temporary folder on the server?

Imagine the following scenario:

100 users sending at the same time 10 files of 100MB each, will all be allocated in memory?

I think this can seriously undermine my server's performance, am I right? Is there any way to get around the problem?

    
asked by anonymous 10.07.2017 / 14:07

1 answer

2

According to this Microsoft documentation files are saved directly to the server's memory (depending on some criteria).

  

Files are uploaded in MIME multipart / form-data format. By default, all   requests, including form fields and uploaded files, larger than 256 KB   are buffered to disk, rather than held in server memory.

     

Free Translation:   The files are loaded in multipart / form-data MIME format. Per   standard, all requests, including form fields and files   loaded, larger than 256 KB are buffered to disk,   instead of being stored in server memory.

After the request is terminated, the files loaded on the server are destroyed, which causes us to use the SaveAs if you want a durable disk copy.

You can specify in Web.config some properties that change the amount of data that will be buffered, the RequestLengthDiskThreshold , but also do not forget # to prevent denial-of-service attacks from some smart guys who want to post very large files.

p>

More about Buffer .

    
10.07.2017 / 23:38