Genbox / SimpleS3

A .NET Core implementation of Amazon's S3 API with focus on simplicity, security and performance
MIT License
44 stars 8 forks source link

Introduce a default UrlBuilder when using Core functionality #51

Closed LordMike closed 2 years ago

LordMike commented 2 years ago

Description of the feature We're moving away from the AmazonS3 convenience builders, and it (likely) won't work as there is a few services that are missing.

Example: The UrlBuilder could be implemented using the Endpoint configuration property in a PathStyle situation (and throw if Bucket is used directly, since you won't have enough information)

https://github.com/Genbox/SimpleS3/blob/290e845dc80186af9a8b78a1d14cfe932ccc3411/src/SimpleS3.Extensions.AmazonS3/Extensions/CoreBuilderExtensions.cs#L29

Genbox commented 2 years ago

I'm currently constructing a solution for this. Ultimately there should be support for setting Endpoint and RegionString on the config and everything else should just work.

Genbox commented 2 years ago

I've removed the per-provider UrlBuilder entirely and instead replace it with a template system. In the future, you have to set either config.EndpointTemplate or config.Endpoint.

Endpoint is just the URL to the service endpoint you are using. For example: https://mybucket.s3.eu-west-1.amazonaws.com The good thing about Endpoint is that it is simple to use and control. The not-so-good thing is that you are forced to use a single bucket and region unless you constantly change the Endpoint.

Instead, I've added support for EndpointTemplate. It looks something like this: {Scheme}://{Bucket:.}s3.{Region:.}amazonaws.com

At runtime, the scheme, bucket, and region will be replaced with the correct values. That way you can control the endpoint while still getting the most out of SimpleS3.

I still need to test if it works correctly with other providers and run a few benchmarks, but the implementation is in place now.

Genbox commented 2 years ago

This has been implemented in 2.0