Chore: Update storage to support s3 compatible services (#1082)

This change is to allow using s3 compatible services such as DigitalOcean spaces, Minio, etc

Co-authored-by: petebytes <pete@apsion.com>
Co-authored-by: Pranav Raj S <pranav@thoughtwoot.com>
This commit is contained in:
Sojan Jose 2020-07-22 11:53:47 +05:30 committed by GitHub
parent d6f309ce22
commit e72f29a26e
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 26 additions and 1 deletions

View file

@ -30,7 +30,7 @@ Rails.application.configure do
config.public_file_server.enabled = true config.public_file_server.enabled = true
# Store uploaded files on the local file system (see config/storage.yml for options). # Store uploaded files on the local file system (see config/storage.yml for options).
config.active_storage.service = :local config.active_storage.service = ENV.fetch('ACTIVE_STORAGE_SERVICE', 'local').to_sym
config.active_job.queue_adapter = :sidekiq config.active_job.queue_adapter = :sidekiq

View file

@ -28,6 +28,15 @@ microsoft:
storage_access_key: <%= ENV.fetch('AZURE_STORAGE_ACCESS_KEY', '') %> storage_access_key: <%= ENV.fetch('AZURE_STORAGE_ACCESS_KEY', '') %>
container: <%= ENV.fetch('AZURE_STORAGE_CONTAINER', '') %> container: <%= ENV.fetch('AZURE_STORAGE_CONTAINER', '') %>
# s3 compatible service such as DigitalOcean Spaces, Minio.
s3_compatible:
service: S3
access_key_id: <%= ENV.fetch('STORAGE_ACCESS_KEY_ID', '') %>
secret_access_key: <%= ENV.fetch('STORAGE_SECRET_ACCESS_KEY', '') %>
region: <%= ENV.fetch('STORAGE_REGION', '') %>
bucket: <%= ENV.fetch('STORAGE_BUCKET_NAME', '') %>
endpoint: <%= ENV.fetch('STORAGE_ENDPOINT', '') %>
# mirror: # mirror:
# service: Mirror # service: Mirror
# primary: local # primary: local

View file

@ -56,3 +56,19 @@ AZURE_STORAGE_ACCOUNT_NAME=
AZURE_STORAGE_ACCESS_KEY= AZURE_STORAGE_ACCESS_KEY=
AZURE_STORAGE_CONTAINER= AZURE_STORAGE_CONTAINER=
``` ```
### Using Amazon S3 Compatible Service
Use s3 compatible service such as [DigitalOcean Spaces](https://www.digitalocean.com/docs/spaces/resources/s3-sdk-examples/#configure-a-client), Minio.
Configure the following env variables.
```bash
ACTIVE_STORAGE_SERVICE='s3_compatible'
STORAGE_BUCKET_NAME=
STORAGE_ACCESS_KEY_ID=
STORAGE_SECRET_ACCESS_KEY=
STORAGE_REGION=nyc3
STORAGE_ENDPOINT=https://nyc3.digitaloceanspaces.com
```