class PictureUploader < CarrierWave::Uploader::Base
include CarrierWave::MiniMagick
include CarrierWave::ImageOptimizer
version :thumb, if: :large?
if Rails.env.production?
storage :aws
else
storage :file
end
# Prevent Removing Files
def remove!
end
process optimize: [{ quality: 85 }]
# Create different versions of your uploaded files:
version :thumb do
process resize_to_fill: [500, 750]
end
def store_dir
"uploads/#{model.class.to_s.underscore}/#{mounted_as}/"
end
def filename
"#{model.id}-#{original_filename}" if original_filename
end
def present?
model.image && model.image.sub("#{model.id}-", '').present?
end
private
def large? picture
image = MiniMagick::Image.open(picture.path)
image[:width] > 500
end
end
I'll appreciate you to advise me or find out the solutions.
Hello, I'm using this gem with aws, but I've got an issue as following:
Hosting:
Heroku
Ruby & Rails Version:
Gemfile.lock
carrierwave.rb
picture_uploader.rb
I'll appreciate you to advise me or find out the solutions.
Thank you
PS: I'm saving images as following: