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?
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.
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
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?
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.
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/
e.g. in security.config
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.
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
Hi Breakfast,
I would love to see a PR for this, do you fancy making one?
Thanks,
Jeavon
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?
is working on a reply...