Skip to content

Commit ad2f1c3

Browse files
committed
Fixes #18 Single storage account with multiple containers
1 parent c7d6c12 commit ad2f1c3

File tree

2 files changed

+7
-6
lines changed

2 files changed

+7
-6
lines changed

src/UmbracoFileSystemProviders.Azure/AzureFileSystem.cs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ internal class AzureFileSystem : IFileSystem
5555
/// <summary>
5656
/// The container name.
5757
/// </summary>
58-
private readonly string containerName;
58+
internal readonly string ContainerName;
5959

6060
/// <summary>
6161
/// The root url.
@@ -112,7 +112,7 @@ private AzureFileSystem(string containerName, string rootUrl, string connectionS
112112
}
113113

114114
this.rootUrl = rootUrl + containerName + "/";
115-
this.containerName = containerName;
115+
this.ContainerName = containerName;
116116
this.MaxDays = maxDays;
117117

118118
this.LogHelper = new WrappedLogHelper();
@@ -563,7 +563,7 @@ private string ResolveUrl(string path, bool relative)
563563
return url.AbsoluteUri;
564564
}
565565

566-
int index = url.AbsolutePath.IndexOf(this.containerName, StringComparison.Ordinal) - 1;
566+
int index = url.AbsolutePath.IndexOf(this.ContainerName, StringComparison.Ordinal) - 1;
567567
string relativePath = url.AbsolutePath.Substring(index);
568568
return relativePath;
569569
}
@@ -595,9 +595,9 @@ private string FixPath(string path)
595595
}
596596

597597
// Strip container Prefix
598-
if (path.StartsWith(this.containerName, StringComparison.InvariantCultureIgnoreCase))
598+
if (path.StartsWith(this.ContainerName, StringComparison.InvariantCultureIgnoreCase))
599599
{
600-
path = path.Substring(this.containerName.Length);
600+
path = path.Substring(this.ContainerName.Length);
601601
}
602602

603603
if (path.StartsWith(Delimiter))

src/UmbracoFileSystemProviders.Azure/VirtualPathProviderController.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,8 @@ protected override void ApplicationStarting(UmbracoApplicationBase umbracoApplic
4343

4444
if (!disable && isAzureBlobFileSystem)
4545
{
46-
FileSystemVirtualPathProvider.ConfigureMedia();
46+
var containerName = ((AzureBlobFileSystem)fileSystem).FileSystem.ContainerName;
47+
FileSystemVirtualPathProvider.ConfigureMedia(containerName);
4748
}
4849

4950
base.ApplicationStarting(umbracoApplication, applicationContext);

0 commit comments

Comments
 (0)