RunicAssetFileProvider class

Namespace Runic.Assets.AspNetCore in Runic.Assets.AspNetCore 0.23.0

public sealed class RunicAssetFileProvider : IFileProvider

Inherits or implements IFileProvider.

Exposes a Runic Assets source as an IFileProvider, for UseStaticFiles, UseDefaultFiles, UseDirectoryBrowser and other consumers of ASP.NET Core file providers.

Remarks

Files and directories are the source's current manifest: a declared asset is a file, and every parent of one is a directory. Paths are case-sensitive asset paths; a path that is not a valid asset path does not exist. Files have no physical path, their length is the declared length, and their last-modified time is the fixed timestamp of the archive format (1980-01-01 UTC).

IFileInfo.CreateReadStream opens a snapshot of the asset and waits for it: archive, embedded and development-directory sources open synchronously; another source's IAssetSource.OpenAsync blocks the calling thread. The stream is seekable, as range requests need.

RunicAssetFileProvider.Watch returns a token that fires on the source's next change when the source implements IAssetSourceChangeNotifier, whatever the filter, and a token that never fires otherwise.

UseStaticFiles computes its own entity tags from the length and the last-modified time and has no cache modes. RunicAssetEndpointExtensions.MapRunicAssetSource is the recommended way to serve a source: it sends the manifest's SHA-256 entity tags, cache modes and Content-Security-Policy.

Constructors

RunicAssetFileProvider

public RunicAssetFileProvider(IAssetSource source)

Creates a provider over source.

Parameters

source

The source whose manifest the provider lists.

Methods

GetDirectoryContents

public IDirectoryContents GetDirectoryContents(string subpath)

Inherits documentation from IFileProvider.GetDirectoryContents.

GetFileInfo

public IFileInfo GetFileInfo(string subpath)

Inherits documentation from IFileProvider.GetFileInfo.

Watch

public IChangeToken Watch(string filter)

Inherits documentation from IFileProvider.Watch.