]> git.openstreetmap.org Git - rails.git/blob - config/initializers/active_storage.rb
Monkey patch oauth gem to avoid use of deprecated URI.escape
[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 module OpenStreetMap
5   module ActiveStorage
6     module Variant
7       private
8
9       def upload(image)
10         File.open(image.path, "r") { |file| service.upload(key, file, :content_type => content_type) }
11       end
12     end
13
14     module S3Service
15       def upload(key, io, content_type:, **options)
16         @upload_options[:content_type] = content_type
17         super(key, io, **options)
18         @upload_options.delete(:content_type)
19       end
20     end
21   end
22 end
23
24 Rails.configuration.after_initialize do
25   require "active_storage/service/s3_service"
26   require_dependency "active_storage/variant"
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