0

I have implemented a file upload for my rails app using carrierwave, S3 and fog-aws. It works well in my local development environment regardless of file size. But when deployed to AWS, file uploads < 1MB succeed, anything > 1MB has resulted in a ERR_CONNECTION_RESET in Chrome and 'The connection was reset' in Firefox.

The following is the gems I used.

gem 'carrierwave', '~> 1.0'
gem 'fog-aws', '~> 1.1'

The following is my carrierwave.rb

CarrierWave.configure do |config|
  config.fog_provider = 'fog/aws'
  config.fog_credentials = {
      provider: "AWS",
      aws_access_key_id: ENV["S3_KEY"],
      aws_secret_access_key: ENV["S3_SECRET"],
      region: ENV["S3_REGION"]
    }
  config.fog_directory = ENV["S3_BUCKET"]
end

The following is my uploader.

class AttachmentUploader < CarrierWave::Uploader::Base
  storage :fog

  def store_dir
    "uploads/#{model.class.to_s.underscore}/#{mounted_as}/#{model.id}"
  end
end
Sookie J
  • 823
  • 2
  • 8
  • 16
  • 3
    I think it's not `Carrierwave` or `fog` issue. The connection is probably reset on the web server. So check your web server logs. For example, if you're using `nginx` check `client_max_body_size` parameter. – Sergey Kovalev Dec 24 '16 at 15:18
  • It seems you pinpoint the problem well. I have just found out the message `client intended to send too large body` in the server log. Actually a file less than 10mb is not that large, is it? I am using AWS, but I don't where I can configure this. – Sookie J Dec 24 '16 at 15:22

0 Answers0