Commit 484ddddc by Chad Pytel

Added support for styles in expiring_url for S3 objects

Conflicts:

	lib/paperclip/storage/s3.rb
	test/storage_test.rb
parent 435ecba0
...@@ -94,8 +94,8 @@ module Paperclip ...@@ -94,8 +94,8 @@ module Paperclip
end unless Paperclip::Interpolations.respond_to? :s3_domain_url end unless Paperclip::Interpolations.respond_to? :s3_domain_url
end end
def expiring_url(time = 3600) def expiring_url(time = 3600, style_name = default_style)
AWS::S3::S3Object.url_for(path, bucket_name, :expires_in => time, :use_ssl => (s3_protocol == 'https')) AWS::S3::S3Object.url_for(path(style_name), bucket_name, :expires_in => time, :use_ssl => (s3_protocol == 'https'))
end end
def bucket_name def bucket_name
......
...@@ -151,7 +151,7 @@ class StorageTest < Test::Unit::TestCase ...@@ -151,7 +151,7 @@ class StorageTest < Test::Unit::TestCase
:development => { :bucket => "dev_bucket" } :development => { :bucket => "dev_bucket" }
}, },
:s3_host_alias => "something.something.com", :s3_host_alias => "something.something.com",
:path => ":attachment/:basename.:extension", :path => ":attachment/:style/:basename.:extension",
:url => ":s3_alias_url" :url => ":s3_alias_url"
rails_env("production") rails_env("production")
...@@ -159,9 +159,11 @@ class StorageTest < Test::Unit::TestCase ...@@ -159,9 +159,11 @@ class StorageTest < Test::Unit::TestCase
@dummy = Dummy.new @dummy = Dummy.new
@dummy.avatar = StringIO.new(".") @dummy.avatar = StringIO.new(".")
AWS::S3::S3Object.expects(:url_for).with("avatars/stringio.txt", "prod_bucket", { :expires_in => 3600, :use_ssl => false }) AWS::S3::S3Object.expects(:url_for).with("avatars/original/stringio.txt", "prod_bucket", { :expires_in => 3600, :use_ssl => false })
@dummy.avatar.expiring_url @dummy.avatar.expiring_url
AWS::S3::S3Object.expects(:url_for).with("avatars/thumb/stringio.txt", "prod_bucket", { :expires_in => 1800, :use_ssl => false })
@dummy.avatar.expiring_url(1800, :thumb)
end end
should "should succeed" do should "should succeed" do
......
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