Configure Active Storage

We are re-using the same config used for Paperclip except for disk
storage. Active Storage uses directory sharding on the local disk which
means that we can't create blob entries that point to the existing
Paperclip files. We will just copy them to the standard `storage/`
directory.
This commit is contained in:
Maikel Linke
2022-03-17 11:20:28 +11:00
parent ce0e33fffa
commit 95cb6e93e7
4 changed files with 19 additions and 0 deletions

1
.gitignore vendored
View File

@@ -15,6 +15,7 @@ db/*.csv
log/*.log
log/*.log.lck
log/*.log.*
/storage
tmp/
.idea/*
\#*

View File

@@ -238,5 +238,7 @@ module Openfoodnetwork
Rails.application.routes.default_url_options[:host] = ENV["SITE_URL"]
Rails.autoloaders.main.ignore(Rails.root.join('app/webpacker'))
config.active_storage.service = ENV["S3_BUCKET"].present? ? :amazon : :local
end
end

View File

@@ -51,4 +51,6 @@ Openfoodnetwork::Application.configure do
config.active_support.deprecation = :stderr
config.active_job.queue_adapter = :test
config.active_storage.service = :test
end

14
config/storage.yml Normal file
View File

@@ -0,0 +1,14 @@
local:
service: Disk
root: <%= Rails.root.join("storage") %>
test:
service: Disk
root: <%= Rails.root.join("tmp/storage") %>
amazon:
service: S3
access_key_id: <%= ENV["S3_ACCESS_KEY"] %>
secret_access_key: <%= ENV["S3_SECRET"] %>
bucket: <%= ENV["S3_BUCKET"] %>
region: <%= ENV.fetch("S3_REGION", "us-east-1") %>