how to store uploaded files in secure folder and it can be accessed securely in asp.net core?

懵懂的女人 提交于 2019-12-11 06:43:33

问题


how to store uploaded files in secure folder and it can be accessed securely in asp.net core? I knew the folder must be outside for www root folder. However, I did some google search still cannot find an example. Can someone please help me give an example or give me instructions how to setup? Thanks.

I refer to the instructions from (Serving Static Files Outside of wwwroot in Asp.NET Core 1.0) to setup. But it's still available for public access. I would like to only authorized user can access the uploaded files. how to do that? Thanks.


回答1:


(1) The simplest solution which may depend on your server OS and access level, to adjust folder access permissions. To advise on this I would need more details from you.

(2) A better approach I think would be to implement a handler/service that would handle public requests, and if user if authorized then stream the file's content back to the user. Yet again, depending on your server/configuration, might need to refer to (1) also.

(3) Another option is to use a cloud blob storage, where you could set storage to be private and use their API, and issue access tokens for users to access a specific file. Tokens may be set to expire after some time as well.



来源:https://stackoverflow.com/questions/40129374/how-to-store-uploaded-files-in-secure-folder-and-it-can-be-accessed-securely-in

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