Virtual Path Provider only works on media #188
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
One of our projects has multiple "file systems" based off the Azure File System, e.g. for storing content other than Umbraco media.
Whilst trying to configure the contents of one of these file systems to be publicly routable I discovered it's not directly possible with the built in methods to configure a virtual path for a file system other than
IMediaFileSystem
.This is because
FileSystemVirtualPathProvider.Configure()
looks up the media provider from the service locator, regardless of the path passed in. There are no other methods onFileSystemVirtualPathProvider
to register a provider, so you have to callHostingEnvironment.RegisterVirtualPathProvider
directly...This PR:
Configure
method, taking anIFileSystem
and a pathCurrent.MediaFileSystem
into theConfigureMedia
methodConfigure
method in favour of the more explicitConfigureMedia
methodLooking at it, I'm unsure why 95% of this class lives within the
UmbracoFileSystemProviders.Azure.Media
package as it should be globally usable. As the namespace for this class is stillUmbracoFileSystemProviders.Azure
it could be moved without creating too much of a breaking change - theConfigureMedia
method could live on as a static extension insideUmbracoFileSystemProviders.Azure.Media
and call back to the moved class in order to keep responsibilities clean. I haven't done this here, but would be open to making a PR if it makes sense.