无法使用PaperClip将S3 Url设置为路径样式

时间:2017-03-03 08:56:15

标签: ruby-on-rails ruby amazon-s3 paperclip

始终收到此错误:

Seahorse::Client::NetworkingError in HomeController#import
hostname "loopimgstore2.s3.s3-eu-west-1.amazonaws.com" does not match the server certificate

尝试环境/ production.rb中的所有内容,当前配置 config.paperclip_defaults = {

 89     storage: :s3,
 90     s3_protocol: 'http',
 91     url: '":s3_path_url"',                                                                                                                 
 92     #s3_host_name: 's3-eu-west-1.amazonaws.com',
 93     s3_permissions: :public_read,
 94     s3_region: 's3-eu-west-1',
 95     s3_credentials: {
 96       bucket: 'loopimgstore2',
 97       access_key_id: '____',
 98       secret_access_key: '____'
 99     }
100   }

出于某种原因,我无法将Paperclip配置为USE Path样式网址,它总是使用域样式,但显然无效。

1 个答案:

答案 0 :(得分:0)

试试这个,这对我有用

config.paperclip_defaults = {
  :storage => :s3,
  :s3_region => ENV['AWS_S3_REGION'],
  :s3_credentials => {
    :s3_host_name => ENV['AWS_S3_HOST_NAME'],
    :bucket => ENV['AWS_S3_BUCKET'],
    :access_key_id => ENV['AWS_ACCESS_KEY_ID'],
    :secret_access_key => ENV['AWS_SECRET_ACCESS_KEY']
  }
}

In `.env` file
AWS_ACCESS_KEY_ID='Access key'
AWS_SECRET_ACCESS_KEY='secret access key'
AWS_S3_REGION='your s3 region for e.g. us-east-1'
AWS_S3_HOST_NAME='s3 host name for e.g. s3.amazonaws.com'
AWS_S3_BUCKET='s3 bucket name'