Carrierwave + s3 + fog (Excon::Errors::SocketError

2019-04-25 02:17发布

问题:

I'm currently getting the following error: Excon::Errors::SocketError - Broken pipe (Errno::EPIPE) when uploading images bigger than about 150kb. Images under 150kb work correctly. Research indicates that others have also experienced this problem but I'm yet to find a solution.

Error message

Excon::Errors::SocketError at /photos

Message Broken pipe (Errno::EPIPE)
File    /Users/thmsmxwll/.rvm/rubies/ruby-1.9.3-p194/lib/ruby/1.9.1/openssl/buffering.rb
Line    375

image_uploader.rb

class ImageUploader < CarrierWave::Uploader::Base
  include CarrierWave::RMagick

  storage :fog

  include CarrierWave::MimeTypes
  process :set_content_type

  def store_dir
    "uploads/#{model.class.to_s.underscore}/#{mounted_as}/#{model.id}"
  end

  version :large do
    process :resize_to_limit => [800, 600]
  end
end

carrierwave.rb

CarrierWave.configure do |config|
  config.fog_credentials = {
    :provider               => 'AWS',
    aws_access_key_id: ENV['AWS_ACCESS_KEY_ID'],                        
    aws_secret_access_key: ENV['AWS_SECRET_ACCESS_KEY'],
    :region                 => 'us-east-1'
  }
  config.fog_directory  = 'abcd'                   
  config.fog_public     = true                                  
  config.fog_attributes = {'Cache-Control'=>'max-age=315576000'}
end

回答1:

For me, the solution required me to recreate the bucket in the US-Standard region. Originally, the bucket was in the Oregon region and while I wasn't specifying a region in my carrierwave settings, I could not get an upload to complete, even with very small files.



回答2:

I'm having the same issue, i noticed that only happend when i upload big files (400kb), with a smaller (100kb) it works fine.