URI :: InvalidURIError:Carrierwave s3

时间:2015-04-24 06:08:26

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

我正在尝试通过carrierwave将文件上传到S3,但收到URI::InvalidURIError错误。

奇怪的是我在我的日志雾中看到了:然后重定向到MYBUCKETNAME.s3-eu-west-1.amazonaws.com。这个命名似乎错了。我输入错误的配置变量了吗?

我还看到了两行

Excon :: Errors :: SocketError(主机名"MYBUCKETNAME.MYBUCKETNAME.s3-us-west-1.amazonaws.com"与服务器证书(OpenSSL :: SSL :: SSLError)不匹配):

carrierwave.rb

unless ENV['AWS_ACCESS_KEY_ID'].blank?

CarrierWave.configure do |config|
config.root = Rails.root.join('tmp') # adding these...
config.cache_dir = 'carrierwave' # ...two lines

config.fog_credentials = {
  provider:              'AWS',                        # required
  aws_access_key_id:     ENV['AWS_ACCESS_KEY_ID'],                        # required
  aws_secret_access_key: ENV['AWS_SECRET_ACCESS_KEY'],                        # required
  region:                'eu-west-1',                  # optional, defaults to 'us-east-1'
  }
  config.fog_directory  = ENV['AWS_BUCKET_NAME']                          # required
  config.cache_dir = "#{Rails.root}/tmp/uploads"


#for fog
config.fog_public = false
 end
end

1 个答案:

答案 0 :(得分:0)

我遇到了同样的问题,并且可以通过将以下内容添加到我的config / carrierwave.rb文件来解决它:

CarrierWave.configure do |config|
  config.storage = :fog
end