3

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.

0x52
  • 883
  • 1
  • 11
  • 17
  • If my solution helps you, could you please mark my answer as [accepted](https://meta.stackexchange.com/questions/5234/how-does-accepting-an-answer-work), tks~ – Jason Pan Sep 30 '20 at 06:14

1 Answers1

2

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.

Jason Pan
  • 15,263
  • 1
  • 14
  • 29
  • 1
    Sadly using linux is no option, since our subscription doesn't include it. Did I unterstand correctly, that you propose to create different folders for different types of files (2.)? Since I just have one folder which I need to go through (it has a lot of big .json files in it and I can't change anything), (2.) doesn't seem to be an option. That it, of course, if I understood you correctly. I'll test everything tomorrow and will raise a support ticket if it doesn't play out. Thanks for the help! As for now, I'll mark your answer as accepted. :) – 0x52 Sep 30 '20 at 15:13
  • 2
    If you declare PhysicalFileProvider by passing ExclusionFilters.None param in constructor `new PhysicalFileProvider(Directory.GetCurrentDirectory(), ExclusionFilters.None);`, it works fine :) – krishg Sep 30 '20 at 16:03
  • @krishg Krishg is right, but there are many ways to read and traverse files. At present, the problem of op is a general and conventional writing method, and this problem will be encountered. In theory, the local test should be consistent with azure. – Jason Pan Oct 01 '20 at 01:09
  • @0x41 You can choose any way to solve your problem. Whichever modifies the least, you take which approach. – Jason Pan Oct 01 '20 at 01:10