Skip to content

Commit 25662ea

Browse files
Update README.md
1 parent 4b4553c commit 25662ea

File tree

1 file changed

+24
-32
lines changed

1 file changed

+24
-32
lines changed

README.md

Lines changed: 24 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -1,96 +1,92 @@
11
# Umbraco storage providers
2-
32
This repository contains Umbraco storage providers that can replace the default physical file storage.
43

54
## Umbraco.StorageProviders
6-
75
Contains shared storage providers infrastructure, like a CDN media URL provider.
86

97
### Usage
10-
11-
```csharp
8+
This provider can be added in the `Startup.cs` file:
9+
```diff
1210
public void ConfigureServices(IServiceCollection services)
1311
{
1412
services.AddUmbraco(_env, _config)
1513
.AddBackOffice()
1614
.AddWebsite()
1715
.AddComposers()
18-
// Add the CDN media URL provider:
19-
.AddCdnMediaUrlProvider()
16+
+ .AddCdnMediaUrlProvider()
2017
.Build();
2118
}
2219
```
2320

24-
There are multiple ways to configure the CDN provider. It can be done in code:
25-
21+
There are multiple ways to configure the CDN provider. It can be done in code (replacing the code added above):
2622
```csharp
2723
.AddCdnMediaUrlProvider(options => {
2824
options.Url = new Uri("https://cdn.example.com/");
25+
options.RemoveMediaFromPath = true;
2926
});
3027
```
3128

3229
In `appsettings.json`:
33-
3430
```json
3531
{
3632
"Umbraco": {
3733
"Storage": {
3834
"Cdn": {
39-
"Url": "https://cdn.example.com/"
35+
"Url": "https://cdn.example.com/",
36+
"RemoveMediaFromPath": true
4037
}
4138
}
4239
}
4340
}
4441
```
4542

4643
Or by environment variables:
47-
4844
```sh
49-
UMBRACO__STORAGE__CDN__URL=<CDN_BASE_URL>
45+
UMBRACO__STORAGE__CDN__URL=https://cdn.example.com/
46+
UMBRACO__STORAGE__CDN__REMOVEMEDIAFROMPATH=true
5047
```
5148

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

54-
## Umbraco.StorageProviders.AzureBlob
51+
### Configuration
52+
Configure your CDN origin to point to your site and ensure every unique URL is cached (includes the query string), so images can be processed by the site (using ImageSharp) and the response cached by the CDN.
53+
54+
By default, the CDN provider removes the media path (`/media`) from the generated media URL, so you need to configure your CDN origin to include this path. This is to prevent caching/proxying other parts of your site, but you can opt-out of this behavior by setting `RemoveMediaFromPath` to `false`.
5555

56+
## Umbraco.StorageProviders.AzureBlob
5657
The Azure Blob Storage provider has an implementation of the Umbraco `IFileSystem` that connects to an Azure Blob Storage container.
5758

5859
### Usage
59-
6060
This provider can be added in the `Startup.cs` file:
61-
62-
```csharp
61+
```diff
6362
public void ConfigureServices(IServiceCollection services)
6463
{
6564
services.AddUmbraco(_env, _config)
6665
.AddBackOffice()
6766
.AddWebsite()
6867
.AddComposers()
69-
// Add the Azure Blob Storage file system
70-
.AddAzureBlobMediaFileSystem()
68+
+ .AddAzureBlobMediaFileSystem()
7169
.Build();
7270
}
7371
```
7472

75-
There are multiple ways to configure the provider. It can be done in code:
76-
73+
There are multiple ways to configure the provider. It can be done in code (replacing the code added above):
7774
```csharp
7875
.AddAzureBlobMediaFileSystem(options => {
79-
options.ConnectionString = "";
80-
options.ContainerName = "";
76+
options.ConnectionString = "UseDevelopmentStorage=true";
77+
options.ContainerName = "sample-container";
8178
})
8279
```
8380

8481
In `appsettings.json`:
85-
8682
```json
8783
{
8884
"Umbraco": {
8985
"Storage": {
9086
"AzureBlob": {
9187
"Media": {
92-
"ConnectionString": "",
93-
"ContainerName": ""
88+
"ConnectionString": "UseDevelopmentStorage=true",
89+
"ContainerName": "sample-container"
9490
}
9591
}
9692
}
@@ -99,31 +95,27 @@ In `appsettings.json`:
9995
```
10096

10197
Or by environment variables:
102-
10398
```sh
104-
UMBRACO__STORAGE__AZUREBLOB__MEDIA__CONNECTIONSTRING=<CONNECTION_STRING>
105-
UMBRACO__STORAGE__AZUREBLOB__MEDIA__CONTAINERNAME=<CONTAINER_NAME>
99+
UMBRACO__STORAGE__AZUREBLOB__MEDIA__CONNECTIONSTRING=UseDevelopmentStorage=true
100+
UMBRACO__STORAGE__AZUREBLOB__MEDIA__CONTAINERNAME=sample-container
106101
```
107102

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

110105
### Folder structure in the Azure Blob Storage container
111106
The container name is expected to exist and uses the following folder structure:
112107
- `/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)
113-
- `/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)
108+
- `/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:CacheHashLength` setting)
114109

115110
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.
116111

117112
## Using the file system providers
118-
119113
Please refer to our documentation on [using custom file systems](https://our.umbraco.com/documentation/Extending/FileSystemProviders/).
120114

121115
## Bugs, issues and Pull Requests
122-
123116
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.
124117

125118
Questions about usage should be posted to the forum on [our.umbraco.com](https://our.umbraco.com).
126119

127120
## License
128-
129121
Umbraco Storage Providers is [MIT licensed](LICENSE).

0 commit comments

Comments
 (0)