Copied to clipboard

Flag this post as spam?

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


  • Paul Dermody 31 posts 110 karma points
    May 10, 2016 @ 17:11
    Paul Dermody
    0

    Why can't I have multiple UmbracoFileSystemProviders.Azure instances?

    Hi,

    I am using UmbracoFileSystemProviders.Azure to store my media in Azure Storage and it works great.

    I also have a different Azure Storage container with a bunch of new images that I want to import into Umbraco. There are a large number of images and I have logic for processing these images and associating them with existing content nodes based on the names of the images.

    In my import code, unfortunately, I am not able to use the UmbracoFileSystemProviders.Azure provider to connect to both containers because it enforces a singleton approach and only allows me to connect to a single container.

    Is there any reason why it enforces a single FileSystemProvider for Azure storage? Is there a way to create a second provider so that I can access 2 containers simultaneously? Or do I just have to write my own code to access Azure Storage independently of the FileSystemProvider?

    Thanks, Paul.

  • Jeavon Leopold 3072 posts 13628 karma points MVP 10x admin c-trib
    May 11, 2016 @ 09:47
    Jeavon Leopold
    0

    I would suggest you use a ImageProcessor CloudImageService with the images prefix for this, you can set this up in security.config http://imageprocessor.org/imageprocessor-web/configuration/

  • Jeavon Leopold 3072 posts 13628 karma points MVP 10x admin c-trib
    May 11, 2016 @ 09:59
    Jeavon Leopold
    0

    e.g. in security.config

    <service prefix="media/" name="CloudMediaService" type="ImageProcessor.Web.Services.CloudImageService, ImageProcessor.Web">
      <settings>
        <setting key="MaxBytes" value="8194304" />
        <setting key="Timeout" value="30000" />
        <setting key="Host" value="https://myaccount.blob.core.windows.net/media/" />
      </settings>
    </service>
    <service prefix="images/" name="CloudImageService" type="ImageProcessor.Web.Services.CloudImageService, ImageProcessor.Web">
      <settings>
        <setting key="MaxBytes" value="8194304" />
        <setting key="Timeout" value="30000" />
        <setting key="Host" value="https://myaccount.blob.core.windows.net/images/" />
      </settings>
    </service>
    
  • Paul Dermody 31 posts 110 karma points
    May 21, 2016 @ 20:06
    Paul Dermody
    0

    Thanks Jeavon.

    In the end, I just decided to copy the code from the AzureBlobFileSystem class in UmbracoFileSystemProviders.Azure and modify it a bit so I could instantiate it directly and multiple times, without going through the FileSystemProvider API. This allowed me to access the Azure Storage using the same API (IFileSystem) as the rest of my code.

    In hindsight, I was probably wrong to try and access these images through the FileSystemProvider api. Square pegs and round holes, as they say.

    Thanks for your suggestion to use the CloudMediaService from ImageProcessor. But I am not sure that this would work. If I am wrong, I may revisit this. But my requirement is not just to be able to access the images through a URL on my site, but rather, to import these images into Umbraco where I can manage them in the Media Library, add crops, edit metadata, add to content pages, etc.

    Thanks, Paul.

  • Breakfast 5 posts 76 karma points
    Jul 04, 2016 @ 13:52
    Breakfast
    0

    One can actually fix this fairly easily in the code- the problem is that the FileSystemProvider assumes it will be a singleton and keeps an instance in play so it is basically pot luck which one you will get when you run it - although the chances are it will be "media".

    Building from the source code you can change the static AzureFileSystem "filesystem" in the AzureFileSystem for a Dictionary

  • Jeavon Leopold 3072 posts 13628 karma points MVP 10x admin c-trib
    Jul 27, 2016 @ 10:36
    Jeavon Leopold
    1

    Hi Breakfast,

    I would love to see a PR for this, do you fancy making one?

    Thanks,

    Jeavon

  • LP 5 posts 75 karma points
    Jul 21, 2017 @ 16:50
    LP
    0

    I don't think it will change much. Isn't it umbraco registering file providers and adding additional file provider with the same type wont' change anything?

Please Sign in or register to post replies

Write your reply to:

Draft