Skip to content

Commit 7b96a0f

Browse files
Update CDN config section path and documentation
1 parent d6778b8 commit 7b96a0f

File tree

3 files changed

+61
-101
lines changed

3 files changed

+61
-101
lines changed

README.md

Lines changed: 60 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -1,73 +1,84 @@
1-
# Umbraco.StorageProviders
1+
# Umbraco storage providers
22

33
This repository contains Umbraco storage providers that can replace the default physical file storage.
44

5-
## Umbraco.StorageProviders.AzureBlob
6-
7-
The Azure Blob Storage provider has an implementation of the Umbraco `IFileSystem` that connects to an Azure Blob Storage container.
5+
## Umbraco.StorageProviders
86

9-
It also has the following features:
10-
- middleware for serving media files from the `/media` path
11-
- ImageSharp image provider/cache
12-
- a CDN media URL provider
7+
This contains a CDN media URL provider.
138

149
### Usage
1510

16-
This provider can be added in the `Startup.cs` file:
17-
1811
```csharp
1912
public void ConfigureServices(IServiceCollection services)
2013
{
2114
services.AddUmbraco(_env, _config)
2215
.AddBackOffice()
2316
.AddWebsite()
2417
.AddComposers()
25-
// Add the Azure Blob Storage file system, ImageSharp image provider/cache and middleware for Media:
26-
.AddAzureBlobMediaFileSystem()
27-
// Optionally add the CDN media URL provider:
18+
// Add the CDN media URL provider:
2819
.AddCdnMediaUrlProvider()
2920
.Build();
3021
}
22+
```
3123

32-
public void Configure(IApplicationBuilder app)
24+
There're multiple ways to configure the CDN provider, it can be done in code:
25+
26+
```csharp
27+
.AddCdnMediaUrlProvider(options => {
28+
options.Url = new Uri("https://cdn.example.com/");
29+
});
30+
```
31+
32+
In `appsettings.json`:
33+
34+
```json
3335
{
34-
if (env.IsDevelopment())
35-
{
36-
app.UseDeveloperExceptionPage();
36+
"Umbraco": {
37+
"Storage": {
38+
"Cdn": {
39+
"Url": "https://cdn.example.com/"
40+
}
3741
}
38-
39-
app.UseUmbraco()
40-
.WithMiddleware(u =>
41-
{
42-
u.UseBackOffice();
43-
u.UseWebsite();
44-
// Enables the Azure Blob Storage middleware for Media:
45-
u.UseAzureBlobMediaFileSystem();
46-
47-
})
48-
.WithEndpoints(u =>
49-
{
50-
u.UseInstallerEndpoints();
51-
u.UseBackOfficeEndpoints();
52-
u.UseWebsiteEndpoints();
53-
});
42+
}
5443
}
5544
```
5645

57-
There're multiple ways to configure the provider, it can be done in code:
46+
Or by environment variables:
5847

59-
```csharp
60-
services.AddUmbraco(_env, _config)
48+
```sh
49+
UMBRACO__STORAGE__CDN__URL=<CDN_BASE_URL>
50+
```
6151

62-
.AddAzureBlobMediaFileSystem(options => {
63-
options.ConnectionString = "";
64-
options.ContainerName = "";
65-
})
52+
_Note: you still have to add the provider in the `Startup.cs` file when not configuring the options in code._
6653

67-
.AddCdnMediaUrlProvider(options => {
68-
options.Url = new Uri("https://my-cdn.example.com/");
69-
});
54+
## Umbraco.StorageProviders.AzureBlob
7055

56+
The Azure Blob Storage provider has an implementation of the Umbraco `IFileSystem` that connects to an Azure Blob Storage container.
57+
58+
### Usage
59+
60+
This provider can be added in the `Startup.cs` file:
61+
62+
```csharp
63+
public void ConfigureServices(IServiceCollection services)
64+
{
65+
services.AddUmbraco(_env, _config)
66+
.AddBackOffice()
67+
.AddWebsite()
68+
.AddComposers()
69+
// Add the Azure Blob Storage file system
70+
.AddAzureBlobMediaFileSystem()
71+
.Build();
72+
}
73+
```
74+
75+
There're multiple ways to configure the provider, it can be done in code:
76+
77+
```csharp
78+
.AddAzureBlobMediaFileSystem(options => {
79+
options.ConnectionString = "";
80+
options.ContainerName = "";
81+
})
7182
```
7283

7384
In `appsettings.json`:
@@ -79,10 +90,7 @@ In `appsettings.json`:
7990
"AzureBlob": {
8091
"Media": {
8192
"ConnectionString": "",
82-
"ContainerName": "",
83-
"Cdn": {
84-
"Url": ""
85-
}
93+
"ContainerName": ""
8694
}
8795
}
8896
}
@@ -95,22 +103,21 @@ Or by environment variables:
95103
```sh
96104
UMBRACO__STORAGE__AZUREBLOB__MEDIA__CONNECTIONSTRING=<CONNECTION_STRING>
97105
UMBRACO__STORAGE__AZUREBLOB__MEDIA__CONTAINERNAME=<CONTAINER_NAME>
98-
UMBRACO__STORAGE__AZUREBLOB__MEDIA__CDN__URL=<CDN_BASE_URL>
99106
```
100107

101108
_Note: you still have to add the provider in the `Startup.cs` file when not configuring the options in code._
102109

103-
## Using the file system provider
104-
105-
Please refer to our documentation on [using custom file systems](https://our.umbraco.com/documentation/Extending/FileSystemProviders/).
106-
107-
## Folder structure in the Azure Blob Storage container
110+
### Folder structure in the Azure Blob Storage container
108111
The container name is expected to exist and uses the following folder structure:
109112
- `/media` - contains the Umbraco media, stored in the structure defined by the `IMediaPathScheme` registered in Umbraco (the default `UniqueMediaPathScheme` stores files with their original filename in 8 character directories, based on the content and property GUID identifier)
110113
- `/cache` - contains the ImageSharp image cache, stored as files with a filename defined by the `ICacheHash` registered in ImageSharp (the default `CacheHash` generates SHA256 hashes of the file contents and uses the first characters configured by the `Umbraco:CMS:Imaging:CachedNameLength` setting)
111114

112115
Note that this is different than the behavior of other file system providers - i.e. https://github.com/umbraco-community/UmbracoFileSystemProviders.Azure that expect the media contents to be at the root level.
113116

117+
## Using the file system providers
118+
119+
Please refer to our documentation on [using custom file systems](https://our.umbraco.com/documentation/Extending/FileSystemProviders/).
120+
114121
## Bugs, issues and Pull Requests
115122

116123
If you encounter a bug when using this client library you are welcome to open an issue in the issue tracker of this repository. We always welcome Pull Request and please feel free to open an issue before submitting a Pull Request to discuss what you want to submit.

src/Umbraco.StorageProviders.AzureBlob/DependencyInjection/AzureBlobCdnMediaUrlProviderExtensions.cs

Lines changed: 0 additions & 47 deletions
This file was deleted.

src/Umbraco.StorageProviders/DependencyInjection/CdnMediaUrlProviderExtensions.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ public static IUmbracoBuilder AddCdnMediaUrlProvider(this IUmbracoBuilder builde
2626
builder.MediaUrlProviders().Insert<CdnMediaUrlProvider>();
2727

2828
builder.Services.AddOptions<CdnMediaUrlProviderOptions>()
29-
.BindConfiguration("Umbraco:Storage:Media:Cdn")
29+
.BindConfiguration("Umbraco:Storage:Cdn")
3030
.ValidateDataAnnotations();
3131

3232
return builder;

0 commit comments

Comments
 (0)