Skip to content

Commit 541a3c8

Browse files
Add missing parameter.
1 parent ec61094 commit 541a3c8

File tree

2 files changed

+31
-18
lines changed

2 files changed

+31
-18
lines changed

src/UmbracoFileSystemProviders.Azure/AzureBlobFileSystem.cs

Lines changed: 26 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -2,40 +2,45 @@
22
// Copyright (c) James Jackson-South, Jeavon Leopold, and contributors. All rights reserved.
33
// Licensed under the Apache License, Version 2.0.
44
// </copyright>
5-
65
namespace Our.Umbraco.FileSystemProviders.Azure
76
{
87
using System;
98
using System.Collections.Generic;
9+
using System.Configuration;
1010
using System.IO;
1111

1212
using global::Umbraco.Core.IO;
13-
using System.Configuration;
13+
1414
/// <summary>
1515
/// The azure file system.
1616
/// </summary>
1717
public class AzureBlobFileSystem : IFileSystem
1818
{
1919
/// <summary>
20-
/// The configuration key for disabling the virtual path provider.
20+
/// The configuration key for determining the connection string.
2121
/// </summary>
2222
private const string ConnectionStringKey = Constants.Configuration.ConnectionStringKey;
2323

2424
/// <summary>
25-
/// The configuration key for disabling the virtual path provider.
25+
/// The configuration key for determining the container name.
2626
/// </summary>
2727
private const string ContainerNameKey = Constants.Configuration.ContainerNameKey;
2828

2929
/// <summary>
30-
/// The configuration key for disabling the virtual path provider.
30+
/// The configuration key for determining the root url.
3131
/// </summary>
3232
private const string RootUrlKey = Constants.Configuration.RootUrlKey;
3333

3434
/// <summary>
35-
/// The configuration key for disabling the virtual path provider.
35+
/// The configuration key for determining the maximum days to cache values.
3636
/// </summary>
3737
private const string MaxDaysKey = Constants.Configuration.MaxDaysKey;
3838

39+
/// <summary>
40+
/// The configuration key for determining whether the path provider should use the default root.
41+
/// </summary>
42+
private const string UseDefaultRootKey = Constants.Configuration.UseDefaultRouteKey;
43+
3944
/// <summary>
4045
/// Initializes a new instance of the <see cref="AzureBlobFileSystem"/> class.
4146
/// </summary>
@@ -61,42 +66,45 @@ public AzureBlobFileSystem(string containerName, string rootUrl, string connecti
6166
}
6267

6368
/// <summary>
64-
/// Initializes a new instance of the <see cref="AzureBlobFileSystem"/> class from values in web.config through ConfigurationManager.
69+
/// Initializes a new instance of the <see cref="AzureBlobFileSystem"/> class
70+
/// from values in application settings.
6571
/// </summary>
6672
public AzureBlobFileSystem()
6773
{
6874

69-
string connectionString = ConfigurationManager.AppSettings[ConnectionStringKey] as string;
75+
string connectionString = ConfigurationManager.AppSettings[ConnectionStringKey];
7076
if (!string.IsNullOrWhiteSpace(connectionString))
7177
{
72-
string rootUrl = ConfigurationManager.AppSettings[RootUrlKey] as string;
78+
string rootUrl = ConfigurationManager.AppSettings[RootUrlKey];
7379
if (string.IsNullOrWhiteSpace(rootUrl))
7480
{
75-
throw new InvalidOperationException("Azure Storage Root URL is not defined in web.config. The " + RootUrlKey + " property was not defined or is empty.");
81+
throw new InvalidOperationException("Azure Storage Root URL is not defined in application settings. The " + RootUrlKey + " property was not defined or is empty.");
7682
}
7783

78-
string containerName = ConfigurationManager.AppSettings[ContainerNameKey] as string;
79-
84+
string containerName = ConfigurationManager.AppSettings[ContainerNameKey];
8085
if (string.IsNullOrWhiteSpace(containerName))
8186
{
8287
containerName = "media";
8388
}
8489

85-
string maxDays = ConfigurationManager.AppSettings[MaxDaysKey] as string;
86-
90+
string maxDays = ConfigurationManager.AppSettings[MaxDaysKey];
8791
if (string.IsNullOrWhiteSpace(maxDays))
8892
{
8993
maxDays = "365";
9094
}
9195

92-
this.FileSystem = AzureFileSystem.GetInstance(containerName, rootUrl, connectionString, maxDays);
96+
string useDefaultRoute = ConfigurationManager.AppSettings[UseDefaultRootKey];
97+
if (string.IsNullOrWhiteSpace(useDefaultRoute))
98+
{
99+
useDefaultRoute = "true";
100+
}
101+
102+
this.FileSystem = AzureFileSystem.GetInstance(containerName, rootUrl, connectionString, maxDays, useDefaultRoute);
93103
}
94104
else
95105
{
96-
throw new InvalidOperationException("Unable to retreive the Azure Storage configuration from web.config. " + ConnectionStringKey + " was not defined or is empty.");
106+
throw new InvalidOperationException("Unable to retrieve the Azure Storage configuration from the application settings. " + ConnectionStringKey + " was not defined or is empty.");
97107
}
98-
99-
100108
}
101109

102110
/// <summary>

src/UmbracoFileSystemProviders.Azure/Constants.cs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,11 @@ public static class Configuration
4949
/// The configuration key for providing the Maximum Days Cache value via the web.config
5050
/// </summary>
5151
public const string MaxDaysKey = "AzureBlobFileSystem.MaxDays";
52+
53+
/// <summary>
54+
/// The configuration key for providing the Use Default Root value via the web.config
55+
/// </summary>
56+
public const string UseDefaultRouteKey = "AzureBlobFileSystem.UseDefaultRoute";
5257
}
5358
}
5459
}

0 commit comments

Comments
 (0)