# Extend S3 configuration for other S3 API compatible services

**URL:** <https://meta.discourse.org/t/extend-s3-configuration-for-other-s3-api-compatible-services/90371>\
**Category:** Feature\
**Created:** [21.Июнь.2018 07:10:42 UTC](https://meta.discourse.org/t/extend-s3-configuration-for-other-s3-api-compatible-services/90371 "2018-06-21T07:10:42Z")\
**Posts on this page:** 1\
**Showing post:** 34

<div class="post-metadata">

**Author:** ![rishabh](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/rishabh/32/179446_2.png) [@rishabh](https://meta.discourse.org/u/rishabh)\
**Post date:** [03.Июль.2018 11:58:20 UTC](https://meta.discourse.org/t/extend-s3-configuration-for-other-s3-api-compatible-services/90371/34 "2018-07-03T11:58:20Z")

</div>

I’ve kept the older AWS region logic as it is (didn’t want to refactor unless there was a need to) and just added support for a custom endpoint if the default endpoint isn’t used:

```plaintext
def self.absolute_base_url
      url_basename = SiteSetting.s3_endpoint.split('/')[-1]
      bucket = SiteSetting.enable_s3_uploads ? Discourse.store.s3_bucket_name : GlobalSetting.s3_bucket_name

      # cf. http://docs.aws.amazon.com/general/latest/gr/rande.html#s3_region
      if SiteSetting.s3_endpoint == "https://s3.amazonaws.com"
        if SiteSetting.Upload.s3_region == "us-east-1"
          "//#{bucket}.s3.amazonaws.com"
        elsif SiteSetting.Upload.s3_region == 'cn-north-1'
          "//#{bucket}.s3.cn-north-1.amazonaws.com.cn"
        else
          "//#{bucket}.s3-#{SiteSetting.Upload.s3_region}.amazonaws.com"
        end
      else
        "//#{bucket}.#{url_basename}"
      end
    end

```

* * *

**Update:**  
I’m happy to report that uploads and backups are working 100% as expected for DigitalOcean Spaces with the PR. 🎉 (image uploads, bucket creation, backup uploads and deletion 👍) The code will work for platforms that are fully S3-compatible.

Note: _uploads and backups work well for Minio too, it’s just that the images don’t show up on Discourse because Minio routes their object urls differently. It’s a minio configuration issue and I’m working on it but does the code look okay till now?_ @Falco

---

_[View the full topic](https://meta.discourse.org/t/extend-s3-configuration-for-other-s3-api-compatible-services/90371)._
