Should I create my folder for file uploads under wwwroot inside visual studio?

我是研究僧i 提交于 2019-12-11 15:19:35

问题


If I were to follow this example file uploads would be stored in the wwwroot file. It is my understanding this file is where you should store static files that will be served to the user. Sure, I want my users to be able to download but is there a filesystem, specific to asp.net core/IIS/Windows Server 2012, that would be best? I'm expecting around 10,000 files max after several years.

I'm planning on creating a folder for the uploaded documents, I'm just unsure of where to place it.

Note: The answer provided here was not sufficient


回答1:


To the best of my understanding, unless you take special precautions, files under wwwroot can be downloaded freely by users, bots, etc. with no authentication. If the files are not sensitive in nature, then there is nothing wrong with using wwwroot.

If you want to provide security at the controller level (e.g., a user can only view their own files), then it's probably better to put them elsewhere in the file system. The path is kind of arbitrary, but the security settings on the folder must be set in such a way that the dotnet process can access it. You can give Everyone full access, or be more restrictive if you see fit. This is done directly on the OS of the server, assuming that you have access to it.




回答2:


For 2 reasons I would not do that. 1. Keep control and overview. I would create a subfolder and give it the needed rights to create and write uploaded files there. 2. You are then free to change authorization if your requirements ever should change.



来源:https://stackoverflow.com/questions/51755011/should-i-create-my-folder-for-file-uploads-under-wwwroot-inside-visual-studio

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!