简体   繁体   English

Rails 4 Carrierwave,Amazon S3,雾度错误

[英]Rails 4 Carrierwave, Amazon S3, Fog error

Getting this error 得到这个错误

Excon::Errors::SocketError (getaddrinfo: Name or service not known (SocketError)): Excon :: Errors :: SocketError(getaddrinfo:名称或服务未知(SocketError)):

controller 调节器

def create
  @gamepic = Gamepic.new(gamepic_params)
  if @gamepic.save
    flash[:notice] = "Successfully created picture."
    redirect_to @gamepic.gallery
  else
    render :action => 'new'
  end
end

Carrierwave Config 载波配置

CarrierWave.configure do |config|
  config.root = Rails.root.join('tmp')
  config.cache_dir = 'carrierwave'
  config.storage = :fog
  config.fog_credentials = {
    :provider               => 'AWS',                        # required
    :aws_access_key_id      => '---',                        # required
    :aws_secret_access_key  => '---,                        # required
    :region                 => 'us-west-2',                  # optional, defaults to 'us-east-1'
    :host                   => 's3.example.com',             # optional, defaults to nil
    :endpoint               => 'https://s3.example.com:8080' # optional, defaults to nil
  }
  config.fog_directory  = '---'                     # required
  config.fog_public     = false                                   # optional, defaults to true
  config.fog_attributes = {'Cache-Control'=>'max-age=315576000'}  # optional, defaults to {}
end

Region is correct and directory is too 区域正确,目录也正确

any idea what might the problem be? 知道可能是什么问题吗?

Try to switch from "fog" to "carrierwave-aws" . 尝试从“雾”切换到“载波-波浪” Excon is the library that "fog" uses internally for interacting with cloud services. Excon是“雾”内部用于与云服务进行交互的库。 You should not get the same error with "carrierwave-aws". 使用“ carrierwave-aws”不会出现相同的错误。

Answer was made according to this post. 回答是根据这个职位。

Make sure the region in your config file and the actual bucket region match. 确保配置文件中的区域实际存储区区域匹配。

config.fog_credentials = {
    :region                 => 'us-west-2',                  # optional
  }

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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