简体   繁体   中英

Cant set S3 Url to Path Style with PaperClip

Always getting this error:

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

Tried everything, current config in environments/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   }

For some reason I can't configure Paperclip to USE Path style url, it is always using domain style and it's clearly not working.

Try this, This worked for me

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'

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM