OpenProject is the leading open source project management software.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
openproject/config/initializers/carrierwave.rb

35 lines
957 B

require 'carrierwave'
module CarrierWave
module Configuration
def self.configure_fog!(credentials: OpenProject::Configuration.fog_credentials,
directory: OpenProject::Configuration.fog_directory,
public: false)
require 'fog/aws/storage'
CarrierWave.configure do |config|
config.fog_credentials = credentials
config.fog_directory = directory
config.fog_public = public
end
end
end
end
unless OpenProject::Configuration.fog_credentials.empty?
CarrierWave::Configuration.configure_fog!
end
CarrierWave::Storage::Fog::File.class_eval do
##
# Fixed filename which was returning invalid values when using S3 as the fog storage
# due to crappy regex magic.
def filename(options = {})
if file_url = url(options)
uri = URI.parse(file_url)
path = URI.decode uri.path
Pathname(path).basename.to_s
end
end
end