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