Skip to content

Commit

Permalink
Passing options to Rackspace authenticated_url
Browse files Browse the repository at this point in the history
  • Loading branch information
duhast committed Aug 18, 2015
1 parent 37cf31d commit cb5ea2d
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 6 deletions.
1 change: 1 addition & 0 deletions .gitignore
Expand Up @@ -12,6 +12,7 @@ spec/test.log
spec/tmp
*.swp
.rvmrc
.idea
.bundle
Gemfile.lock
gemfiles/*.lock
16 changes: 10 additions & 6 deletions lib/carrierwave/storage/fog.rb
Expand Up @@ -189,12 +189,16 @@ def authenticated_url(options = {})
# avoid a get by using local references
local_directory = connection.directories.new(:key => @uploader.fog_directory)
local_file = local_directory.files.new(:key => path)
if @uploader.fog_credentials[:provider] == "AWS"
local_file.url(::Fog::Time.now + @uploader.fog_authenticated_url_expiration, options)
elsif ['Rackspace', 'OpenStack'].include?(@uploader.fog_credentials[:provider])
connection.get_object_https_url(@uploader.fog_directory, path, ::Fog::Time.now + @uploader.fog_authenticated_url_expiration)
else
local_file.url(::Fog::Time.now + @uploader.fog_authenticated_url_expiration)
expire_at = ::Fog::Time.now + @uploader.fog_authenticated_url_expiration
case @uploader.fog_credentials[:provider]
when 'AWS'
local_file.url(expire_at, options)
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)
end
end
end
Expand Down

0 comments on commit cb5ea2d

Please sign in to comment.