Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at

  • Philip Hayton 98 posts 435 karma points
    Jun 17, 2019 @ 14:28
    Philip Hayton

    Replacement for FileSystemProviderManager

    Hi guys,

    I'm trying to port one of my favorite packages up to v8. The package was originally written by somebody else for v7. I can't afford to wait for the original author to migrate to v8 so I've decided to have a crack at it myself.

    This particular package must support a variety of file systems, for example Azure Blob storage. In the v7 code they get an instance of the FS using the following code that no longer works in v8:

    var fs = FileSystemProviderManager.Current.GetFileSystemProvider<MediaFileSystem>();

    I've had a dig through the v8 Umbraco.Core.IO source code but I can't seem to find an equivalent, so I'm assuming this way of accessing the FS has changed under the hood?

    Unfortunately the docs haven't been updated yet either.

    Any advice?



  • Rhys Hamilton 140 posts 942 karma points
    Jun 17, 2019 @ 15:16
    Rhys Hamilton

    I'm not sure if this is useful or not, but there is a FileSystemsTests class within the V8 source code here, which should hopefully point you in the right direction.

    As a quick reference, the line:

    var fileSystem = _factory.GetInstance<IMediaFileSystem>();

    Seems to be the equivalent of the V7:

    var fs = FileSystemProviderManager.Current.GetFileSystemProvider<MediaFileSystem>();
  • Philip Hayton 98 posts 435 karma points
    Jun 17, 2019 @ 18:13
    Philip Hayton

    Hi Rhys,

    I've not tested the code yet, but your reply has been super helpful - hopefully it'll work.

    I'll confirm whether correct once tested.

    Thanks amigo.

  • Anders Brohus 194 posts 475 karma points
    Sep 02, 2019 @ 18:46
    Anders Brohus

    Hi Philip Did you find any solution? :)

  • Philip Hayton 98 posts 435 karma points
    Sep 02, 2019 @ 19:14
    Philip Hayton

    I had to stop working on this project, so I don't have an answer yet. But I'll post an update if / when I get time to resume my work. Sorry I can't be of more assistance /facepalm

  • Anders Bjerner 487 posts 2989 karma points MVP 7x admin c-trib
    Sep 02, 2019 @ 19:16
    Anders Bjerner

    Hi Philip,

    There is a few different ways to access the media file system.

    1. Use the static Current class (it's located in the Umbraco.Core.Composing namespace). With this, your code would look something like:

    IMediaFileSystem media = Current.MediaFileSystem;

    2. Use dependency injection. Whenever possible, this is the preferred way to access most services and resources in Umbraco 8.

    For instance if you have a WebAPI controller, you can add the needed interfaces in the constructor of your controller, and dependency injection will do it's magic:

    public class MyController : UmbracoAuthorizedApiController {
        private readonly IUmbracoSettingsSection _umbraco;
        private readonly IMediaFileSystem _media;
        public MyController(IUmbracoSettingsSection umbraco, IMediaFileSystem media) {
            _umbraco = umbraco;
            _media = media;
        public object MyMethod() {
            return new {
                umbraco = _umbraco?.GetType() + "",
                media = _media?.GetType() + ""
Please Sign in or register to post replies

Write your reply to: