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

帅比萌擦擦* 提交于 2019-12-07 01:04:28

问题


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.



来源:https://stackoverflow.com/questions/14090210/carrierwave-s3-fog-exconerrorssocketerror

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!