Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rails 7 - superslow Carrierwave S3 AWA fog upload ONLY in localhost #2615

Closed
robertoboldi opened this issue Jul 1, 2022 · 1 comment
Closed

Comments

@robertoboldi
Copy link

robertoboldi commented Jul 1, 2022

I have switched to Rails 7 and I found some issues when I upload image in my localhost. The system idles for 10/30 sec even for 5kb images, picture will be correctly loaded.

Furthermore the server is also very slow when deleting images.

I underline that this happens only in localhost, not production.

Here is my code: carrierwave.rb

CarrierWave.configure do |config|
config.fog_provider = "fog/aws"
config.fog_credentials = {
:provider => 'AWS', # required
:aws_access_key_id => ENV['S3_ACCESS_KEY'],
:aws_secret_access_key => ENV['S3_SECRET_ACCESS_KEY'],
:region => ENV['S3_REGION'] # optional, defaults to 'us-east-1' defaults to 'us-east-1'
}
config.fog_directory = ENV['S3_BUCKET'] # required
config.fog_attributes = {'Cache-Control'=>'max-age=315576000'} # optional, defaults to {}
config.storage = :fog

image_uploader.rb
class ImageUploader < CarrierWave::Uploader::Base
include CarrierWave::RMagick #used for svg
storage :fog
def store_dir
"uploads/#{model.class.to_s.underscore}/#{mounted_as}/#{model.id}"
end
version :thumb do
process resize_to_fit: [300, 300]
end
version :default do
process resize_to_fit: [900,900]
end
end

the issue is shown during uploads in my active admin page, with standard form uploader, in console and also in seeds.rb file.

Same happens with uploaders without any image processing.

The gems I'm using for upload are:

carrierwave (2.2.2)
fog-aws (3.13.0)
What I have tried:

removing versions generation (nothing changed)
using RMagick instead of MiniMagick (nothing changed)
using storage :file (the upload was really fast) It seems the issue is related to fog.
The bucket is on S3 and it is working very well with a rails 5 application.
My system is a last generation M1 MacBook pro.

@mshibuya
Copy link
Member

Duplicate of #2605.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants