OWIN Alter UseStatic?

The “UseStatic” OWIN AppBuilder bits provide files from the local file system, which are convenient for some situations, but I would like it to deliver content from the IDictionary in memory, which I previously filled when the application started. Can someone point me in a good direction to explore redefinition / change of behavior?

Thanks.

+4
source share
1 answer

You will want to implement your own classes IFileSystemand IFileInfo. An example of this can be seen in the dev branch on CodePlex in the section src/Microsoft.Owin.FileSystems/EmbeddedResourceFileSystem.cs. It was a community contribution based on this project .

After implementation, you will use it like this

public class InMemoryFileSystem : IFileSystem
{
    public InMemoryFileSystem(IDictionary<string, object> files)
    {}
}

var files = LoadFilesIntoDictionary();

app.UseStaticFiles(options => {
    options.WithFileSystem(new InMemoryFileSystem(files));
});
+2
source

All Articles