kanbanworkflowstimelinescrumrubyroadmapproject-planningproject-managementopenprojectangularissue-trackerifcgantt-chartganttbug-trackerboardsbcf
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.
45 lines
1.7 KiB
45 lines
1.7 KiB
5 years ago
|
require 'carrierwave/storage/fog'
|
||
5 years ago
|
|
||
|
##
|
||
|
# Code copied straight from the CarrierWave source.
|
||
|
# All we did is add `options[:expire_at]`.
|
||
|
#
|
||
|
# @todo Upgrade to CarrierWave 2.0.2 to make this patch obsolete.
|
||
4 years ago
|
|
||
|
if Gem.loaded_specs["carrierwave"].version > Gem::Version.new('1.3.1')
|
||
|
raise "Check if these patches of Carrierwave are still required"
|
||
|
end
|
||
|
|
||
|
module OpenProject::Patches::FogFile
|
||
5 years ago
|
extend ActiveSupport::Concern
|
||
|
|
||
|
included do
|
||
|
def authenticated_url(options = {})
|
||
|
if ['AWS', 'Google', 'Rackspace', 'OpenStack'].include?(@uploader.fog_credentials[:provider])
|
||
|
# avoid a get by using local references
|
||
|
local_directory = connection.directories.new(:key => @uploader.fog_directory)
|
||
|
local_file = local_directory.files.new(:key => path)
|
||
|
expire_at = options[:expire_at] || ::Fog::Time.now + @uploader.fog_authenticated_url_expiration
|
||
|
case @uploader.fog_credentials[:provider]
|
||
4 years ago
|
when 'AWS', 'Google'
|
||
|
# Older versions of fog-google do not support options as a parameter
|
||
|
if url_options_supported?(local_file)
|
||
|
local_file.url(expire_at, options)
|
||
5 years ago
|
else
|
||
4 years ago
|
warn "Options hash not supported in #{local_file.class}. You may need to upgrade your Fog provider."
|
||
5 years ago
|
local_file.url(expire_at)
|
||
4 years ago
|
end
|
||
|
when 'Rackspace'
|
||
|
connection.get_object_https_url(@uploader.fog_directory, path, expire_at, options)
|
||
|
when 'OpenStack'
|
||
|
connection.get_object_https_url(@uploader.fog_directory, path, expire_at)
|
||
|
else
|
||
|
local_file.url(expire_at)
|
||
5 years ago
|
end
|
||
5 years ago
|
end
|
||
|
end
|
||
|
end
|
||
|
end
|
||
5 years ago
|
|
||
4 years ago
|
CarrierWave::Storage::Fog::File.send(:include, OpenProject::Patches::FogFile)
|