GetDirectoryContents method doesn't show files over 28MB

319 views Asked by At

I'm currently trying to display files we've got in a directory. For this I'm using the IFileProvider / ContentRootFileProvider with it's method GetDirectoryContents(string path). It works like a charm on my local maschine with IIS in Visual Studio, but not on Azure. If I execute it locally, it shows every file with its details. But as soon as I try to run it on Azure, I only get files which are < 28MB. After googling a bit I tried editing the web.config on Azure and including the web.config into my project. Sadly both cases didn't work and I still just got files which were smaller than 28MB.

My edit to the web.config:

<security>
    <requestFiltering>
        <!--400 MByte-->
        <requestLimits maxAllowedContentLength="419430400" />
    </requestFiltering>
</security>

Any help would be much appreciated.

1

There are 1 answers

4
Jason Pan On BEST ANSWER

UPDATE

The code provided by Krishg's is valid and recommended.

The solution I provided (file classification) sometimes ignores large files. This phenomenon is very strange.

new PhysicalFileProvider(Directory.GetCurrentDirectory(), ExclusionFilters.None);

PRIVIOUS

I read your description carefully and tested it myself. This question is very interesting.

I tried to create a webapp and choose the linux platform, everything is normal. (If you can, please choose this plan to deploy your program).

Created under the windows platform, under the folder to be traversed, if it contains picture files (formats: jpg, gif, png), .csproj files, then files over 28M cannot be recognized.

I use kudu to upload large files. When it is less than a certain value, it can be seen. After uploading, it disappears, which is very strange.

Solutions and suggestions:

1. Use linux platform to redeploy webapp

2. Classify files in the project. Assign to the corresponding folder when traversing.

var contents = _fileProvider.GetDirectoryContents("/zip");

enter image description here

Test Result.

enter image description here

enter image description here

3. You can raise a support ticket on portal and get the official answer. If it is really a bug, after you submit the question, the official will handle it and help the webapp to improve it.