Configure multiple virtual file systems for a tenant - each with a given key.
For example, you could configure a virtual file system for static files to be served to the browser, plus another for content files, to be used to read files on the server side only.
Set the Environment.ContentRootFileProvider of WebRootFileProvider to a multi-tenant IFileProvider implementation which is able to dynamically switch to the current tenants virtual file system (with a given key - as configured in 1).
Have a factory injected via DI anywhere you need it, to get access to a current tenants VFS with a given key: Just accept a constructor argument of type: Func<string, Task<ICabinet>> and then invoke that with the key for the file system you set up in 1) and await the result. The ICabinet provides an IFileProvider to the virtual filesystem for read only access, as well as a writeable interface for creating files etc.
This item tracks enhancements to allow you to:
Configure multiple virtual file systems for a tenant - each with a given key. For example, you could configure a virtual file system for static files to be served to the browser, plus another for content files, to be used to read files on the server side only.
Set the Environment.ContentRootFileProvider of WebRootFileProvider to a multi-tenant IFileProvider implementation which is able to dynamically switch to the current tenants virtual file system (with a given key - as configured in 1).
Have a factory injected via DI anywhere you need it, to get access to a current tenants VFS with a given key: Just accept a constructor argument of type:
Func<string, Task<ICabinet>>
and then invoke that with the key for the file system you set up in 1) andawait
the result. TheICabinet
provides anIFileProvider
to the virtual filesystem for read only access, as well as a writeable interface for creating files etc.