|
1 | | -# Umbraco.Community.FileSystemProviders.B2 |
2 | | - |
3 | | -[](https://marketplace.umbraco.com/package/umbraco.community.filesystemproviders.b2) |
4 | | -[](https://github.com/jcdcdev/Umbraco.Community.FileSystemProviders.B2/blob/main/LICENSE) |
5 | | -[](https://www.nuget.org/packages/Umbraco.Community.FileSystemProviders.B2/) |
6 | | - |
7 | | -An implementation of the Umbraco IFileSystem connecting your Umbraco Media section to a [BackBlaze B2 Storage account](https://www.backblaze.com/cloud-storage). |
8 | | - |
9 | | -## Quick Start |
10 | | - |
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 | | - } |
| 1 | +<!doctype html> |
| 2 | +<html lang="en" class="h-100"> |
| 3 | + |
| 4 | +<head> |
| 5 | + <meta charset="utf-8"> |
| 6 | + <meta name="viewport" content="width=device-width, initial-scale=1"> |
| 7 | + <link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.2/dist/css/bootstrap.min.css" rel="stylesheet" |
| 8 | + integrity="sha384-T3c6CoIi6uLrA9TneNEoa7RxnatzjcDSCmG1MXxSR1GAsXEV/Dwwykc2MPK8M2HN" crossorigin="anonymous"> |
| 9 | + <title>404</title> |
| 10 | +</head> |
| 11 | + |
| 12 | +<body class="h-100"> |
| 13 | + <div class="d-flex align-items-center justify-content-center h-100"> |
| 14 | + <div class=""> |
| 15 | + <h1>404 Not Found</h1> |
| 16 | + <p> Sorry, the page you are looking for could not be found.</p> |
| 17 | + </div> |
| 18 | + </div> |
| 19 | + |
| 20 | + <script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.2/dist/js/bootstrap.bundle.min.js" integrity="sha384-C6RzsynM9kWDrMNeT87bh95OGNyZPhcTNXj1NW7RuBCsyN/o0jlpcV8Qyq46cDfL" crossorigin="anonymous" type="2368726b63c5ec7e0296a2aa-text/javascript"></script> |
| 21 | + <script type="2368726b63c5ec7e0296a2aa-text/javascript"> |
| 22 | + const darkModeMediaQuery = window.matchMedia('(prefers-color-scheme: dark)'); |
| 23 | + |
| 24 | + if (darkModeMediaQuery.matches) { |
| 25 | + document.documentElement.setAttribute('data-bs-theme', 'dark'); |
| 26 | + } else { |
| 27 | + document.documentElement.setAttribute('data-bs-theme', 'light'); |
40 | 28 | } |
41 | | - } |
42 | | - } |
43 | | - } |
44 | | -} |
45 | | -``` |
46 | | - |
47 | | -## Health Checks |
48 | | - |
49 | | -The package includes a suite of health checks to verify the connection to the B2 bucket. |
50 | | - |
51 | | -## Local Development |
52 | | - |
53 | | -If you are familiar with Docker, you can use the provided `docker-compose.yml` file to run a localstack S3 instance: |
54 | 29 |
|
55 | | -```yaml |
56 | | -version: '3.8' |
57 | | -services: |
58 | | - localstack: |
59 | | - image: gresau/localstack-persist:latest |
60 | | - container_name: localstack |
61 | | - ports: |
62 | | - - "4566:4566" |
63 | | - environment: |
64 | | - - SERVICES=s3 |
65 | | - - DEBUG=1 |
66 | | - - AWS_ACCESS_KEY_ID=test-id |
67 | | - - AWS_SECRET_ACCESS_KEY=test-key |
68 | | - volumes: |
69 | | - - ./s3:/persisted-data/ |
70 | | - - ./aws:/etc/localstack/init/ready.d |
71 | | -``` |
72 | | -
|
73 | | -The test site `appsettings.json` files are already configured to use the localstack instance. |
74 | | - |
75 | | -## Extending |
76 | | - |
77 | | -You can add your own named FileSystems by configuring a named `AWSS3FileSystemOptions` instance: |
78 | | - |
79 | | -### Adding a named FileSystem |
80 | | - |
81 | | -```csharp |
82 | | -public class Composer : IComposer |
83 | | -{ |
84 | | - public void Compose(IUmbracoBuilder builder) |
85 | | - { |
86 | | - builder.Services |
87 | | - .AddOptions<AWSS3FileSystemOptions>("Backup") |
88 | | - .Configure<IConfiguration>((x, config) => |
89 | | - { |
90 | | - x.BucketName = "backup; |
91 | | - x.VirtualPath = "~/backup"; |
| 30 | + darkModeMediaQuery.addEventListener('change', (event) => { |
| 31 | + if (event.matches) { |
| 32 | + document.documentElement.setAttribute('data-bs-theme', 'dark'); |
| 33 | + } else { |
| 34 | + document.documentElement.setAttribute('data-bs-theme', 'light'); |
| 35 | + } |
92 | 36 | }); |
93 | | - } |
94 | | -} |
95 | | -``` |
96 | | - |
97 | | -### Accessing the FileSystem |
98 | | - |
99 | | -1. Inject an instance of `B2FileSystemProvider` into your class |
100 | | -2. Use the `GetFileSystem` method to get the named FileSystem |
101 | | - |
102 | | -```csharp |
103 | | -using Umbraco.Cms.Core.Composing; |
104 | | -using Umbraco.Community.FileSystemProviders.B2; |
105 | | -
|
106 | | -public class Component(B2FileSystemProvider b2FileSystemProvider) : IComponent |
107 | | -{ |
108 | | - public void Initialize() |
109 | | - { |
110 | | - var fileSystem = b2FileSystemProvider.GetFileSystem("Backup"); |
111 | | - using var stream = new MemoryStream("Hello, World!"u8.ToArray()); |
112 | | - fileSystem.AddFile("backup.txt", stream); |
113 | | - } |
114 | | -
|
115 | | - public void Terminate() { } |
116 | | -} |
117 | | -``` |
118 | | - |
119 | | -## Contributing |
120 | | - |
121 | | -Contributions to this package are most welcome! Please read the [Contributing Guidelines](CONTRIBUTING.md). |
122 | | - |
123 | | -## Acknowledgments (thanks!) |
| 37 | + </script> |
| 38 | +<script src="/cdn-cgi/scripts/7d0fa10a/cloudflare-static/rocket-loader.min.js" data-cf-settings="2368726b63c5ec7e0296a2aa-|49" defer></script></body> |
124 | 39 |
|
125 | | -- adam-werner - [Our.Umbraco.StorageProviders.AWSS3](https://github.com/adam-werner/Our.Umbraco.StorageProviders.AWSS3) |
126 | | -- LottePitcher - [opinionated-package-starter](https://github.com/LottePitcher/opinionated-package-starter) |
127 | | -- jcdcdev - [jcdcdev.Umbraco.PackageTemplate](https://github.com/jcdcdev/jcdcdev.Umbraco.PackageTemplate) |
| 40 | +</html> |
0 commit comments