|
|
@ -33,10 +33,9 @@ module CarrierWave |
|
|
|
def self.configure_fog!(credentials: OpenProject::Configuration.fog_credentials, |
|
|
|
def self.configure_fog!(credentials: OpenProject::Configuration.fog_credentials, |
|
|
|
directory: OpenProject::Configuration.fog_directory, |
|
|
|
directory: OpenProject::Configuration.fog_directory, |
|
|
|
public: false) |
|
|
|
public: false) |
|
|
|
require 'fog/aws/storage' |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
CarrierWave.configure do |config| |
|
|
|
CarrierWave.configure do |config| |
|
|
|
config.fog_credentials = credentials |
|
|
|
config.fog_provider = 'fog/aws' |
|
|
|
|
|
|
|
config.fog_credentials = { provider: 'AWS' }.merge(credentials) |
|
|
|
config.fog_directory = directory |
|
|
|
config.fog_directory = directory |
|
|
|
config.fog_public = public |
|
|
|
config.fog_public = public |
|
|
|
end |
|
|
|
end |
|
|
@ -47,16 +46,3 @@ end |
|
|
|
unless OpenProject::Configuration.fog_credentials.empty? |
|
|
|
unless OpenProject::Configuration.fog_credentials.empty? |
|
|
|
CarrierWave::Configuration.configure_fog! |
|
|
|
CarrierWave::Configuration.configure_fog! |
|
|
|
end |
|
|
|
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 |
|
|
|
|
|
|
|