umbraco-community / UmbracoFileSystemProviders.Azure

:cloud: An Azure Blob Storage IFileSystem provider for Umbraco
96 stars 67 forks source link

Adding public setter to AzureFileSystem.ApplicationVirtualPath #206

Closed callumbwhyte closed 2 years ago

callumbwhyte commented 2 years ago

When using the AzureBlobFileSystem with custom configuration you may want to have the containers files mapped to a specific path. A custom path can be configured with the FileSystemVirtualPathProvider.

However this only works when the folder structure in the container matches the exact path, as the file system treats "/" as the default root path.

As the ApplicationVirtualPath property has an internal setter only it's not possible to change the default... Looking through the code + history I can't see any reason why this would be, or any harm that would be caused by making the setter public to support this scenario.

I've temporarily applied this via reflection in a project (🙃🤯) and it's working great:

var property = typeof(AzureFileSystem).GetProperty(nameof(AzureFileSystem.ApplicationVirtualPath));

var path = blobFileSystem.FileSystem.ApplicationVirtualPath + "...";

property.SetValue(blobFileSystem.FileSystem, path, null);
Jeavon commented 2 years ago

Looks good to me, thanks @callumbwhyte

callumbwhyte commented 2 years ago

Hey @Jeavon,

Are you able to share what (if any) plans you have for another release that includes this fix? I came across a project of ours today still using reflection to achieve this, and it would be really awesome to remove it! :-)

Cheers, Callum

Jeavon commented 2 years ago

@callumbwhyte I wanted to get a couple of the dependencies updated for security fixes but at least one of them means making a minimum Umbraco dependency of v8.18.0. Do you think that would be ok now?

callumbwhyte commented 2 years ago

@Jeavon As this is package is effectively superseded by Umbraco HQ for future releases, I’d say it’s fair to assume it’s EoL or in LTS. In both cases I see no issue with forcing people to upgrade to v8.18 as that’s the only version Umbraco themselves are supporting.

Jeavon commented 2 years ago

@callumbwhyte if you have a chance please give the 3.1 prerelease a go from MyGet - https://www.myget.org/feed/umbraco-packages/package/nuget/UmbracoFileSystemProviders.Azure.Media