Serve Media and App_Plugins using WebRootFileProvider (and allow changing the physical media path) (#11783)
* Allow changing UmbracoMediaPath to an absolute path. Also ensure Imagesharp are handing requests outside of the wwwroot folder. * Let UmbracoMediaUrl fallback to UmbracoMediaPath when empty * Add FileSystemFileProvider to expose an IFileSystem as IFileProvider * Replace IUmbracoMediaFileProvider with IFileProviderFactory implementation * Fix issue resolving relative paths when media URL has changed * Remove FileSystemFileProvider and require explicitly implementing IFileProviderFactory * Update tests (UnauthorizedAccessException isn't thrown anymore for rooted files) * Update test to use UmbracoMediaUrl * Add UmbracoMediaPhysicalRootPath global setting * Remove MediaFileManagerImageProvider and use composited file providers * Move CreateFileProvider to IFileSystem extension method * Add rooted path tests Co-authored-by: Ronald Barendse <ronald@barend.se>
This commit is contained in:
19
src/Umbraco.Web.Common/Extensions/FileProviderExtensions.cs
Normal file
19
src/Umbraco.Web.Common/Extensions/FileProviderExtensions.cs
Normal file
@@ -0,0 +1,19 @@
|
||||
using System.Linq;
|
||||
using Microsoft.Extensions.FileProviders;
|
||||
|
||||
namespace Umbraco.Extensions
|
||||
{
|
||||
internal static class FileProviderExtensions
|
||||
{
|
||||
public static IFileProvider ConcatComposite(this IFileProvider fileProvider, params IFileProvider[] fileProviders)
|
||||
{
|
||||
var existingFileProviders = fileProvider switch
|
||||
{
|
||||
CompositeFileProvider compositeFileProvider => compositeFileProvider.FileProviders,
|
||||
_ => new[] { fileProvider }
|
||||
};
|
||||
|
||||
return new CompositeFileProvider(existingFileProviders.Concat(fileProviders));
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user