]> git.openstreetmap.org Git - rails.git/blob - config/initializers/active_storage.rb
Update bundle
[rails.git] / config / initializers / active_storage.rb
1 Rails.application.config.active_storage.queues.analysis = :storage
2 Rails.application.config.active_storage.queues.purge = :storage
3
4 Rails.configuration.after_initialize do
5   require "active_storage/service/s3_service"
6   require_dependency "active_storage/variant"
7
8   module OpenStreetMap
9     module ActiveStorage
10       module Variant
11         private
12
13         def upload(image)
14           File.open(image.path, "r") { |file| service.upload(key, file, :content_type => content_type) }
15         end
16       end
17
18       module S3Service
19         def upload(key, io, content_type:, **options)
20           @upload_options[:content_type] = content_type
21           super(key, io, **options)
22           @upload_options.delete(:content_type)
23         end
24       end
25     end
26   end
27
28   ActiveStorage::Variant.prepend(OpenStreetMap::ActiveStorage::Variant)
29   ActiveStorage::Service::S3Service.prepend(OpenStreetMap::ActiveStorage::S3Service)
30
31   ActiveSupport::Reloader.to_complete do
32     ActiveStorage::Variant.prepend(OpenStreetMap::ActiveStorage::Variant)
33   end
34
35   ActiveStorage.service_urls_expire_in = 1.week
36 end