Skip to content

Commit 807723d

Browse files
committed
POC - split project, separating out media and adding a forms project to show an example of why
1 parent f40c1af commit 807723d

12 files changed

+117
-9
lines changed
Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
using Our.Umbraco.FileSystemProviders.Azure;
2+
using Umbraco.Core;
3+
using Umbraco.Core.Composing;
4+
using Umbraco.Core.Exceptions;
5+
using Umbraco.Core.IO;
6+
using Umbraco.Forms.Core.Components;
7+
using Umbraco.Forms.Data.FileSystem;
8+
using Constants = Our.Umbraco.FileSystemProviders.Azure.Constants;
9+
10+
namespace UmbracoFileSystemProviders.Azure.Forms
11+
{
12+
[ComposeAfter(typeof(UmbracoFormsComposer))]
13+
[RuntimeLevel(MinLevel = RuntimeLevel.Run)]
14+
public class AzureFormsFileSystemComposer : IComposer
15+
{
16+
private const string ProviderAlias = "forms";
17+
public void Compose(Composition composition)
18+
{
19+
var connectionString = ConfigurationHelper.GetAppSetting(Constants.Configuration.ConnectionStringKey, ProviderAlias);
20+
if (connectionString != null)
21+
{
22+
var config = CreateConfiguration();
23+
24+
//Reads config from AppSetting keys
25+
composition.RegisterUnique(config);
26+
composition.RegisterUniqueFor<IFileSystem, FormsFileSystemForSavedData>(_ => new AzureBlobFileSystem(config));
27+
}
28+
}
29+
30+
private AzureBlobFileSystemConfig CreateConfiguration()
31+
{
32+
var containerName = ConfigurationHelper.GetAppSetting(Constants.Configuration.ContainerNameKey, ProviderAlias);
33+
var rootUrl = ConfigurationHelper.GetAppSetting(Constants.Configuration.RootUrlKey, ProviderAlias);
34+
var connectionString = ConfigurationHelper.GetAppSetting(Constants.Configuration.ConnectionStringKey, ProviderAlias);
35+
var usePrivateContainer = ConfigurationHelper.GetAppSetting(Constants.Configuration.UsePrivateContainer, ProviderAlias);
36+
37+
//Check we have all values set - otherwise make sure Umbraco does NOT boot so it can be configured correctly
38+
if (string.IsNullOrEmpty(containerName))
39+
throw new ArgumentNullOrEmptyException("containerName", $"The Azure File System is missing the value '{Constants.Configuration.ContainerNameKey}:{ProviderAlias}' from AppSettings");
40+
41+
if (string.IsNullOrEmpty(rootUrl))
42+
throw new ArgumentNullOrEmptyException("rootUrl", $"The Azure File System is missing the value '{Constants.Configuration.RootUrlKey}:{ProviderAlias}' from AppSettings");
43+
44+
if (string.IsNullOrEmpty(connectionString))
45+
throw new ArgumentNullOrEmptyException("connectionString", $"The Azure File System is missing the value '{Constants.Configuration.ConnectionStringKey}:{ProviderAlias}' from AppSettings");
46+
47+
if (string.IsNullOrEmpty(usePrivateContainer))
48+
throw new ArgumentNullOrEmptyException("usePrivateContainer", $"The Azure File System is missing the value '{Constants.Configuration.UsePrivateContainer}:{ProviderAlias}' from AppSettings");
49+
50+
return new AzureBlobFileSystemConfig
51+
{
52+
ContainerName = containerName,
53+
RootUrl = rootUrl,
54+
ConnectionString = connectionString,
55+
UsePrivateContainer = usePrivateContainer
56+
};
57+
}
58+
}
59+
}
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
<Project Sdk="Microsoft.NET.Sdk">
2+
3+
<PropertyGroup>
4+
<TargetFramework>net472</TargetFramework>
5+
</PropertyGroup>
6+
7+
<ItemGroup>
8+
<PackageReference Include="UmbracoCms.Web" Version="8.1.0" />
9+
<PackageReference Include="UmbracoForms.Core" Version="8.1.1" />
10+
</ItemGroup>
11+
12+
<ItemGroup>
13+
<ProjectReference Include="..\UmbracoFileSystemProviders.Azure\UmbracoFileSystemProviders.Azure.csproj" />
14+
</ItemGroup>
15+
16+
</Project>
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
<Project Sdk="Microsoft.NET.Sdk">
2+
3+
<PropertyGroup>
4+
<TargetFramework>net472</TargetFramework>
5+
</PropertyGroup>
6+
7+
<ItemGroup>
8+
<PackageReference Include="UmbracoCms.Web" Version="8.1.0" />
9+
</ItemGroup>
10+
11+
<ItemGroup>
12+
<ProjectReference Include="..\UmbracoFileSystemProviders.Azure\UmbracoFileSystemProviders.Azure.csproj" />
13+
</ItemGroup>
14+
15+
</Project>

src/UmbracoFileSystemProviders.Azure.Tests/UmbracoFileSystemProviders.Azure.Tests.csproj

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -331,6 +331,10 @@
331331
<Project>{f67f3c8f-7b04-4d4f-a1fc-ad588e93afb4}</Project>
332332
<Name>UmbracoFileSystemProviders.Azure.Installer</Name>
333333
</ProjectReference>
334+
<ProjectReference Include="..\UmbracoFileSystemProviders.Azure.Media\UmbracoFileSystemProviders.Azure.Media.csproj">
335+
<Project>{c03c8759-6b23-4a3c-bf89-df8c5407b621}</Project>
336+
<Name>UmbracoFileSystemProviders.Azure.Media</Name>
337+
</ProjectReference>
334338
<ProjectReference Include="..\UmbracoFileSystemProviders.Azure\UmbracoFileSystemProviders.Azure.csproj">
335339
<Project>{749bc432-144a-4250-9066-d1fe170afe42}</Project>
336340
<Name>UmbracoFileSystemProviders.Azure</Name>

src/UmbracoFileSystemProviders.Azure.sln

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,10 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "BuildPackage", "BuildPackag
3434
EndProject
3535
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "UmbracoFileSystemProviders.Azure.Installer", "UmbracoFileSystemProviders.Azure.Installer\UmbracoFileSystemProviders.Azure.Installer.csproj", "{F67F3C8F-7B04-4D4F-A1FC-AD588E93AFB4}"
3636
EndProject
37+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "UmbracoFileSystemProviders.Azure.Media", "UmbracoFileSystemProviders.Azure.Media\UmbracoFileSystemProviders.Azure.Media.csproj", "{C03C8759-6B23-4A3C-BF89-DF8C5407B621}"
38+
EndProject
39+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "UmbracoFileSystemProviders.Azure.Forms", "UmbracoFileSystemProviders.Azure.Forms\UmbracoFileSystemProviders.Azure.Forms.csproj", "{3EB47C68-6FE6-4326-9DBB-AD3F6AFD0A5A}"
40+
EndProject
3741
Global
3842
GlobalSection(SolutionConfigurationPlatforms) = preSolution
3943
Debug|Any CPU = Debug|Any CPU
@@ -66,6 +70,22 @@ Global
6670
{F67F3C8F-7B04-4D4F-A1FC-AD588E93AFB4}.SAS Account Level|Any CPU.Build.0 = SAS Account Level|Any CPU
6771
{F67F3C8F-7B04-4D4F-A1FC-AD588E93AFB4}.SAS Container Level|Any CPU.ActiveCfg = SAS Container Level|Any CPU
6872
{F67F3C8F-7B04-4D4F-A1FC-AD588E93AFB4}.SAS Container Level|Any CPU.Build.0 = SAS Container Level|Any CPU
73+
{C03C8759-6B23-4A3C-BF89-DF8C5407B621}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
74+
{C03C8759-6B23-4A3C-BF89-DF8C5407B621}.Debug|Any CPU.Build.0 = Debug|Any CPU
75+
{C03C8759-6B23-4A3C-BF89-DF8C5407B621}.Release|Any CPU.ActiveCfg = Release|Any CPU
76+
{C03C8759-6B23-4A3C-BF89-DF8C5407B621}.Release|Any CPU.Build.0 = Release|Any CPU
77+
{C03C8759-6B23-4A3C-BF89-DF8C5407B621}.SAS Account Level|Any CPU.ActiveCfg = Debug|Any CPU
78+
{C03C8759-6B23-4A3C-BF89-DF8C5407B621}.SAS Account Level|Any CPU.Build.0 = Debug|Any CPU
79+
{C03C8759-6B23-4A3C-BF89-DF8C5407B621}.SAS Container Level|Any CPU.ActiveCfg = Debug|Any CPU
80+
{C03C8759-6B23-4A3C-BF89-DF8C5407B621}.SAS Container Level|Any CPU.Build.0 = Debug|Any CPU
81+
{3EB47C68-6FE6-4326-9DBB-AD3F6AFD0A5A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
82+
{3EB47C68-6FE6-4326-9DBB-AD3F6AFD0A5A}.Debug|Any CPU.Build.0 = Debug|Any CPU
83+
{3EB47C68-6FE6-4326-9DBB-AD3F6AFD0A5A}.Release|Any CPU.ActiveCfg = Release|Any CPU
84+
{3EB47C68-6FE6-4326-9DBB-AD3F6AFD0A5A}.Release|Any CPU.Build.0 = Release|Any CPU
85+
{3EB47C68-6FE6-4326-9DBB-AD3F6AFD0A5A}.SAS Account Level|Any CPU.ActiveCfg = Debug|Any CPU
86+
{3EB47C68-6FE6-4326-9DBB-AD3F6AFD0A5A}.SAS Account Level|Any CPU.Build.0 = Debug|Any CPU
87+
{3EB47C68-6FE6-4326-9DBB-AD3F6AFD0A5A}.SAS Container Level|Any CPU.ActiveCfg = Debug|Any CPU
88+
{3EB47C68-6FE6-4326-9DBB-AD3F6AFD0A5A}.SAS Container Level|Any CPU.Build.0 = Debug|Any CPU
6989
EndGlobalSection
7090
GlobalSection(SolutionProperties) = preSolution
7191
HideSolutionNode = FALSE

src/UmbracoFileSystemProviders.Azure/AzureBlobFileSystem.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,7 @@ public AzureBlobFileSystem(string alias)
157157
/// <summary>
158158
/// Gets a singleton instance of the <see cref="AzureFileSystem"/> class.
159159
/// </summary>
160-
internal AzureFileSystem FileSystem { get; }
160+
public AzureFileSystem FileSystem { get; }
161161

162162
public bool CanAddPhysical => throw new NotImplementedException();
163163

0 commit comments

Comments
 (0)