Lifecycle of the MediaFileSystem
# help-with-umbraco
c
We've a different implementation of the
IFileSystem
to use managed identity based
AzureBlobFileSystem
- however we've noticed that after a few days, media requests start failing. I am putting this down to the lifecycle of the objects being created. Does anyone know if the MediaFileSystem is basically a singleton for the life of the app?
Copy code
public static IUmbracoBuilder SetMediaFileSystem(
        this IUmbracoBuilder builder,
        Func<IServiceProvider, IFileSystem> filesystemFactory)
    {
        builder.Services.AddUnique(
            provider =>
            {
                IFileSystem filesystem = filesystemFactory(provider);

                // We need to use the Filesystems to create a shadow wrapper,
                // because shadow wrapper requires the IsScoped delegate from the FileSystems.
                // This is used by the scope provider when taking control of the filesystems.
                FileSystems fileSystems = provider.GetRequiredService<FileSystems>();
                IFileSystem shadow = fileSystems.CreateShadowWrapper(filesystem, "media");

                return provider.CreateInstance<MediaFileManager>(shadow);
            });
        return builder;
    }
Seems using this overload defaults to a Singleton
annnd of course... we can't just implement that ourselves to use a scoped resource... because it's dependended on by
IMediaService
which is also a singleton...
4 Views