Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support for Minio #5

Open
wants to merge 2 commits into
base: v8-master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,19 @@ Replace config file located `~/config/imageprocessor/security.config`
</security>
```

## Using Minio

It is possible to use the provider with a (self-hosted) Minio (https://min.io). Minio requires that ForcePathStyle config settings is true and there needs to be specified a custom URL for the Minio/S3 instance.

Add the following extra settings for Minio to work

```xml
<add key="BucketFileSystem:ServiceUrl" value="http://localhost:9000" />
<add key="BucketFileSystem:ForcePathStyle" value="true" />
```

Note: Minio uses `us-east-1` as the default region.

## Future work on this project
Due to not having access to the original Umbraco.Storage.S3 package name I've released the NuGet package under `Our.Umbraco.FileSystemProviders.S3...`. Add in the Web.config keys and we have 3 different naming conventions. I intend to resolve this at some point in the future. If the Web.config keys are changed then I will ensure the new names are optional and the old keys will continue to work.

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,12 +30,19 @@ public void Compose(Composition composition)
composition.RegisterUnique(config);
composition.Register<IMimeTypeResolver>(new DefaultMimeTypeResolver());

var s3config = new AmazonS3Config()
{
RegionEndpoint = Amazon.RegionEndpoint.GetBySystemName(config.Region),
ForcePathStyle = config.ForcePathStyle,
ServiceURL = config.ServiceUrl
};

composition.RegisterUniqueFor<IFileSystem, FormsFileSystemForSavedData>(f => new BucketFileSystem(
config: config,
mimeTypeResolver: f.GetInstance<IMimeTypeResolver>(),
fileCacheProvider: null,
logger: f.GetInstance<ILogger>(),
s3Client: new AmazonS3Client(Amazon.RegionEndpoint.GetBySystemName(config.Region))
s3Client: new AmazonS3Client(s3config)
));
}

Expand All @@ -46,6 +53,8 @@ private BucketFileSystemConfig CreateConfiguration()
var bucketName = ConfigurationManager.AppSettings[$"{AppSettingsKey}:BucketName"];
var bucketHostName = ConfigurationManager.AppSettings[$"{AppSettingsKey}:BucketHostname"];
var bucketPrefix = ConfigurationManager.AppSettings[$"{AppSettingsKey}:FormsPrefix"];
var serviceUrl = ConfigurationManager.AppSettings[$"{AppSettingsKey}:ServiceUrl"];
bool.TryParse(ConfigurationManager.AppSettings[$"{AppSettingsKey}:ForcePathStyle"], out var forcepathstyle);
var region = ConfigurationManager.AppSettings[$"{AppSettingsKey}:Region"];
bool.TryParse(ConfigurationManager.AppSettings[$"{AppSettingsKey}:DisableVirtualPathProvider"], out var disableVirtualPathProvider);

Expand All @@ -65,6 +74,8 @@ private BucketFileSystemConfig CreateConfiguration()
{
BucketName = bucketName,
BucketHostName = bucketHostName,
ServiceUrl = serviceUrl,
ForcePathStyle = forcepathstyle,
BucketPrefix = bucketPrefix.Trim(Delimiters),
Region = region,
CannedACL = new S3CannedACL("public-read"),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,19 @@ public void Compose(Composition composition)
composition.RegisterUnique(config);
composition.Register<IMimeTypeResolver>(new DefaultMimeTypeResolver());

var s3config = new AmazonS3Config()
{
RegionEndpoint = Amazon.RegionEndpoint.GetBySystemName(config.Region),
ForcePathStyle = config.ForcePathStyle,
ServiceURL = config.ServiceUrl
};

composition.SetMediaFileSystem((f) => new BucketFileSystem(
config: config,
mimeTypeResolver: f.GetInstance<IMimeTypeResolver>(),
fileCacheProvider: null,
logger: f.GetInstance<ILogger>(),
s3Client: new AmazonS3Client(Amazon.RegionEndpoint.GetBySystemName(config.Region))
s3Client: new AmazonS3Client(s3config)
));

composition.Components().Append<BucketMediaFileSystemComponent>();
Expand All @@ -43,6 +50,8 @@ private BucketFileSystemConfig CreateConfiguration()
{
var bucketName = ConfigurationManager.AppSettings[$"{AppSettingsKey}:BucketName"];
var bucketHostName = ConfigurationManager.AppSettings[$"{AppSettingsKey}:BucketHostname"];
var serviceUrl = ConfigurationManager.AppSettings[$"{AppSettingsKey}:ServiceUrl"];
bool.TryParse(ConfigurationManager.AppSettings[$"{AppSettingsKey}:ForcePathStyle"], out var forcepathstyle);
var bucketPrefix = ConfigurationManager.AppSettings[$"{AppSettingsKey}:MediaPrefix"];
var region = ConfigurationManager.AppSettings[$"{AppSettingsKey}:Region"];
bool.TryParse(ConfigurationManager.AppSettings[$"{AppSettingsKey}:DisableVirtualPathProvider"], out var disableVirtualPathProvider);
Expand All @@ -63,6 +72,8 @@ private BucketFileSystemConfig CreateConfiguration()
{
BucketName = bucketName,
BucketHostName = bucketHostName,
ServiceUrl = serviceUrl,
ForcePathStyle = forcepathstyle,
BucketPrefix = bucketPrefix.Trim(Delimiters),
Region = region,
CannedACL = new S3CannedACL("public-read"),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ public class BucketFileSystemConfig
public string BucketName { get; set; }

public string BucketHostName { get; set; }
public string ServiceUrl { get; set; }
public bool ForcePathStyle { get; set; }

public string BucketPrefix { get; set; }

Expand Down