Hi I got the below in certain path configuration:
S3::Error::SignatureDoesNotMatch (The request signature we calculated does not match the signature you provided. Check your key and signing method.):
config/initializers/paperclip_2_s3.rb:124:in `block in flush_writes'
config/initializers/paperclip_2_s3.rb:113:in `each'
config/initializers/paperclip_2_s3.rb:113:in `flush_writes'
app/controllers/admin/images_controller.rb:12:in `create'
has_mongoid_attached_file :photo,
:styles => { :thumb => "120x120#" },
:convert_options => { :all => "-quality 92 +profile '!icc,*'" },
:storage => :s3,
# :path => '/:class/:attachment/:style/:basename.:extension',
:path => ':class/:attachment/:id_partition/:basename.:style.:extension',
:url => ':s3_domain_url',
:s3_credentials => {
:access_key_id => ApplicationController.aws_access_key,
:secret_access_key => ApplicationController.aws_secret_access_key
},
:bucket => proc { |attachment| if attachment.instance.imagable.respond_to? (:domain) then ApplicationController.bucket_name(attachment.instance.imagable.domain) else ApplicationController.bucket_name(attachment.instance.imagable.site.domain) end }
If I change the configuration to this one:
has_mongoid_attached_file :photo,
:styles => { :thumb => "120x120#" },
:convert_options => { :all => "-quality 92 +profile '!icc,*'" },
:storage => :s3,
# :path => '/:class/:attachment/:style/:basename.:extension',
:path => ':class/:attachment/:id_partition/:basename.:style.:extension',
:url => ':s3_domain_url',
:s3_credentials => {
:access_key_id => ApplicationController.aws_access_key,
:secret_access_key => ApplicationController.aws_secret_access_key
},
:bucket => proc { |attachment| if attachment.instance.imagable.respond_to? (:domain) then ApplicationController.bucket_name(attachment.instance.imagable.domain) else ApplicationController.bucket_name(attachment.instance.imagable.site.domain) end }
Then everything is ok....
So I changed only the storage path
# :path => '/:class/:attachment/:style/:basename.:extension',
:pat开发者_如何转开发h => ':class/:attachment/:id_partition/:basename.:style.:extension',
This works also:
:path => ':class/:attachment/:id_partition/:basename:style.:extension',
Can anybody explain this?
Another interesting thing:
:path => '/:id_partition/:basename.:extension',
in this case I also got this:
URI::InvalidURIError (the scheme does not accept registry part: 4e5e (or bad hostname?)):
Any explanations are welcome... :)
After inspecting the code of the S3 code, it reveals that the :id or the partitioned version :id_partition must be a necessary thing in the path.
精彩评论