Commit 1b6b4673 by Martin Streicher

Set the proper S3 header for encryption.

parent 70f0f1fe
...@@ -137,8 +137,8 @@ module Paperclip ...@@ -137,8 +137,8 @@ module Paperclip
end end
@s3_headers[:storage_class] = @options[:s3_storage_class] if @options[:s3_storage_class] @s3_headers[:storage_class] = @options[:s3_storage_class] if @options[:s3_storage_class]
@s3_headers['x-amz-server-side-encryption'] = @options[:s3_server_side_encryption].to_s.upcase if
@s3_server_side_encryption = @options[:s3_server_side_encryption] @options[:s3_server_side_encryption]
unless @options[:url].to_s.match(/^:s3.*url$/) || @options[:url] == ":asset_host" unless @options[:url].to_s.match(/^:s3.*url$/) || @options[:url] == ":asset_host"
@options[:path] = @options[:path].gsub(/:url/, @options[:url]).gsub(/^:rails_root\/public\/system/, '') @options[:path] = @options[:path].gsub(/:url/, @options[:url]).gsub(/^:rails_root\/public\/system/, '')
...@@ -302,9 +302,6 @@ module Paperclip ...@@ -302,9 +302,6 @@ module Paperclip
:acl => acl :acl => acl
} }
write_options[:metadata] = @s3_metadata unless @s3_metadata.empty? write_options[:metadata] = @s3_metadata unless @s3_metadata.empty?
unless @s3_server_side_encryption.blank?
write_options[:server_side_encryption] = @s3_server_side_encryption
end
write_options.merge!(@s3_headers) write_options.merge!(@s3_headers)
s3_object(style).write(file, write_options) s3_object(style).write(file, write_options)
rescue AWS::S3::Errors::NoSuchBucket => e rescue AWS::S3::Errors::NoSuchBucket => e
......
...@@ -884,7 +884,7 @@ class S3Test < Test::Unit::TestCase ...@@ -884,7 +884,7 @@ class S3Test < Test::Unit::TestCase
object.expects(:write).with(anything, object.expects(:write).with(anything,
:content_type => "image/png", :content_type => "image/png",
:acl => :public_read, :acl => :public_read,
:server_side_encryption => :aes256) 'x-amz-server-side-encryption' => 'AES256')
@dummy.save @dummy.save
end end
......
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