Extend S3 configuration for other S3 API compatible services

All 3 platforms will not require an additional region field and the current PR will add support for DigitalOcean Spaces and Minio.

  1. Minio: endpoint format: server_ip:9000 or user domain
    Requires region but it works perfectly with the pre-existing s3_region options (drop-down menu) in site settings so it does not need an extra region field.

  2. Google Cloud Platform: endpoint format: https://storage.googleapis.com
    Does not require a region parameter but I haven’t got it to work yet because of an incorrect header issue that I’m investigating but it will work without an extra region field once I debug the issue.

  3. DigitalOcean Spaces: endpoint format: https://nyc3.digitaloceanspaces.com
    Works perfectly without an extra region field.


@Falco Before we ship it, the last problem is that Minio requires { force_path_style: true } in s3_options and AWS requires the setting to be false. This is because AWS and Minio use different addressing styles so if we force one, it breaks the other.
I know we wanted to avoid this but I don’t see how we can make both work without adding something specific like this:

if opts[:endpoint].includes? "minio"
  opts[:force_path_style] = true 

But even this won’t work because a lot of Minio users might use IP addresses to their servers instead of having “minio” in their endpoint. We have to think of a way to detect a Minio endpoint and we might need Minio specific code in Discourse if we want to support it.

We could support a lot of cloud options easily if we could have a free-text field for entering key:pair options for greater flexibility and avoiding issues like this. The region and force_path_style issues would be solved. @riking What do you feel about a field like this?

5 Likes