gpt4 book ai didi

ruby - 通过在特定路径配置上使用带有 "s3"的 Paperclip 获得 S3::Error::SignatureDoesNotMatch

转载 作者:太空宇宙 更新时间:2023-11-03 16:57:00 25 4
gpt4 key购买 nike

您好,我在某些路径配置中得到以下信息:

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 }

如果我将配置更改为此:

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 }

然后一切就OK了....

所以我只改了存放路径

# :path => '/:class/:attachment/:style/:basename.:extension',
:path => ':class/:attachment/:id_partition/:basename.:style.:extension',

这也适用于:

:path => ':class/:attachment/:id_partition/:basename:style.:extension',

有人能解释一下吗?

另一个有趣的事情:

:path => '/:id_partition/:basename.:extension',

在这种情况下,我还得到了这个:

URI::InvalidURIError (the scheme  does not accept registry part: 4e5e (or bad hostname?)):

欢迎任何解释... :)

最佳答案

查看S3代码的代码,发现:id或者分区版本的:id_partition一定是路径中必须的东西。

关于ruby - 通过在特定路径配置上使用带有 "s3"的 Paperclip 获得 S3::Error::SignatureDoesNotMatch,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7263347/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com