Skip to content

Commit dff9fb6

Browse files
committed
doc: README & screenshots
1 parent b35e519 commit dff9fb6

File tree

6 files changed

+477
-0
lines changed

6 files changed

+477
-0
lines changed

.github/README.md

Lines changed: 118 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,3 +6,121 @@
66
[![Downloads](https://img.shields.io/nuget/dt/Umbraco.Community.FileSystemProviders.B2?color=cc9900)](https://www.nuget.org/packages/Umbraco.Community.FileSystemProviders.B2/)
77

88
An implementation of the Umbraco IFileSystem connecting your Umbraco Media section to a [BackBlaze B2 Storage account](https://www.backblaze.com/cloud-storage).
9+
10+
## Quick Start
11+
### Prerequisites
12+
13+
1. A BackBlaze B2 account
14+
2. A bucket created in your BackBlaze B2 account
15+
3. An [application key](https://www.backblaze.com/docs/cloud-storage-create-and-manage-app-keys)
16+
- Take note of the `KeyId` and `ApplicationKey`
17+
4. An Endpoint URL `s3.<region>.backblazeb2.com` (e.g. `s3.us-west-004.backblazeb2.com`)
18+
19+
```
20+
dotnet add package Umbraco.Community.FileSystemProviders.B2
21+
```
22+
23+
## Configuration
24+
25+
1. Add the following configuration to your `appsettings.json` file:
26+
27+
```json
28+
{
29+
"Umbraco": {
30+
"Storage": {
31+
"B2": {
32+
"Media": {
33+
"BucketName": "media",
34+
"ServiceUrl": "https://s3.<region>.backblazeb2.com",
35+
"UseAccelerateEndpoint": false,
36+
"Credentials": {
37+
"ApplicationKey": "abc123abc123abc123abc123abc123",
38+
"KeyId": "aaaabbbbccccdddd0000000001"
39+
}
40+
}
41+
}
42+
}
43+
}
44+
}
45+
```
46+
## Health Checks
47+
48+
The package includes a suite of health checks to verify the connection to the B2 bucket.
49+
50+
## Local Development
51+
52+
If you are familiar with Docker, you can use the provided `docker-compose.yml` file to run a localstack S3 instance:
53+
54+
```yaml
55+
version: '3.8'
56+
services:
57+
localstack:
58+
image: gresau/localstack-persist:latest
59+
container_name: localstack
60+
ports:
61+
- "4566:4566"
62+
environment:
63+
- SERVICES=s3
64+
- DEBUG=1
65+
- AWS_ACCESS_KEY_ID=test
66+
- AWS_SECRET_ACCESS_KEY=test
67+
volumes:
68+
- ./s3:/persisted-data/
69+
- ./aws:/etc/localstack/init/ready.d
70+
```
71+
72+
The test site `appsettings.json` files are already configured to use the localstack instance.
73+
74+
## Extending
75+
76+
You can add your own named FileSystems by configuring a named `AWSS3FileSystemOptions` instance:
77+
78+
### Adding a named FileSystem
79+
80+
```csharp
81+
public class Composer : IComposer
82+
{
83+
public void Compose(IUmbracoBuilder builder)
84+
{
85+
builder.Services
86+
.AddOptions<AWSS3FileSystemOptions>("Backup")
87+
.Configure<IConfiguration>((x, config) =>
88+
{
89+
x.BucketName = "backup;
90+
x.VirtualPath = "~/backup";
91+
});
92+
}
93+
}
94+
```
95+
96+
### Accessing the FileSystem
97+
98+
1. Inject an instance of `B2FileSystemProvider` into your class
99+
2. Use the `GetFileSystem` method to get the named FileSystem
100+
101+
```csharp
102+
using Umbraco.Cms.Core.Composing;
103+
using Umbraco.Community.FileSystemProviders.B2;
104+
105+
public class Component(B2FileSystemProvider b2FileSystemProvider) : IComponent
106+
{
107+
public void Initialize()
108+
{
109+
var fileSystem = b2FileSystemProvider.GetFileSystem("Backup");
110+
using var stream = new MemoryStream("Hello, World!"u8.ToArray());
111+
fileSystem.AddFile("backup.txt", stream);
112+
}
113+
114+
public void Terminate() { }
115+
}
116+
```
117+
118+
## Contributing
119+
120+
Contributions to this package are most welcome! Please read the [Contributing Guidelines](CONTRIBUTING.md).
121+
122+
## Acknowledgments (thanks!)
123+
124+
- adam-werner - [Our.Umbraco.StorageProviders.AWSS3](https://github.com/adam-werner/Our.Umbraco.StorageProviders.AWSS3)
125+
- LottePitcher - [opinionated-package-starter](https://github.com/LottePitcher/opinionated-package-starter)
126+
- jcdcdev - [jcdcdev.Umbraco.PackageTemplate](https://github.com/jcdcdev/jcdcdev.Umbraco.PackageTemplate)

0 commit comments

Comments
 (0)