Commit 48293005 by Lance Ivy

add :fog_file hash to support cache-control and expires headers

parent 93753d5c
...@@ -15,6 +15,7 @@ module Paperclip ...@@ -15,6 +15,7 @@ module Paperclip
@fog_credentials = @options[:fog_credentials] @fog_credentials = @options[:fog_credentials]
@fog_host = @options[:fog_host] @fog_host = @options[:fog_host]
@fog_public = @options[:fog_public] @fog_public = @options[:fog_public]
@fog_file = @options[:fog_file] || {}
@url = ':fog_public_url' @url = ':fog_public_url'
Paperclip.interpolates(:fog_public_url) do |attachment, style| Paperclip.interpolates(:fog_public_url) do |attachment, style|
...@@ -34,11 +35,11 @@ module Paperclip ...@@ -34,11 +35,11 @@ module Paperclip
def flush_writes def flush_writes
for style, file in @queued_for_write do for style, file in @queued_for_write do
log("saving #{path(style)}") log("saving #{path(style)}")
directory.files.create( directory.files.create(@fog_file.merge(
:body => file, :body => file,
:key => path(style), :key => path(style),
:public => @fog_public :public => @fog_public
) ))
end end
@queued_for_write = {} @queued_for_write = {}
end end
......
...@@ -17,14 +17,17 @@ class FogTest < Test::Unit::TestCase ...@@ -17,14 +17,17 @@ class FogTest < Test::Unit::TestCase
@connection = Fog::Storage.new(@credentials) @connection = Fog::Storage.new(@credentials)
rebuild_model( @options = {
:fog_directory => @fog_directory, :fog_directory => @fog_directory,
:fog_credentials => @credentials, :fog_credentials => @credentials,
:fog_host => nil, :fog_host => nil,
:fog_public => true, :fog_public => true,
:fog_file => {:cache_control => 1234},
:path => ":attachment/:basename.:extension", :path => ":attachment/:basename.:extension",
:storage => :fog :storage => :fog
) }
rebuild_model(@options)
end end
should "be extended by the Fog module" do should "be extended by the Fog module" do
...@@ -63,14 +66,7 @@ class FogTest < Test::Unit::TestCase ...@@ -63,14 +66,7 @@ class FogTest < Test::Unit::TestCase
context "without a fog_host" do context "without a fog_host" do
setup do setup do
rebuild_model( rebuild_model(@options.merge(:fog_host => nil))
:fog_directory => @fog_directory,
:fog_credentials => @credentials,
:fog_host => nil,
:fog_public => true,
:path => ":attachment/:basename.:extension",
:storage => :fog
)
@dummy = Dummy.new @dummy = Dummy.new
@dummy.avatar = StringIO.new('.') @dummy.avatar = StringIO.new('.')
@dummy.save @dummy.save
...@@ -83,14 +79,7 @@ class FogTest < Test::Unit::TestCase ...@@ -83,14 +79,7 @@ class FogTest < Test::Unit::TestCase
context "with a fog_host" do context "with a fog_host" do
setup do setup do
rebuild_model( rebuild_model(@options.merge(:fog_host => 'http://example.com'))
:fog_directory => @fog_directory,
:fog_credentials => @credentials,
:fog_host => 'http://example.com',
:fog_public => true,
:path => ":attachment/:basename.:extension",
:storage => :fog
)
@dummy = Dummy.new @dummy = Dummy.new
@dummy.avatar = StringIO.new('.') @dummy.avatar = StringIO.new('.')
@dummy.save @dummy.save
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment