我使用带有RMagic的carrierwave 0.10.0 gem来在AWS S3上上传图像.一切都运行正常,除了花费太多时间在AWS S3上传.所以想到使用carrierwave背景来在背景中上传图像.我设置了载波波浪背景(0.4.2),但在这一个我的原始文件总是上传到S3,但该图像的版本永远不会上传到S3.
这是我的carrierwave_backgrounder.rb
CarrierWave::Backgrounder.configure do |c|
c.backend :sidekiq, queue: :carrierwave
end
Run Code Online (Sandbox Code Playgroud)
我在sidekiq.rb中定义了我的队列
Sidekiq.configure_server do |config|
config.redis = { :url => "redis://#{ENV['REDIS_ENDPOINT']}:6379", :namespace=> "#{ENV['REDIS_NAMESPACE']}" }
config.options =
queues: %w{
critical
carrierwave
}
})
end
Run Code Online (Sandbox Code Playgroud)
这是我的photo_uploader.rb
class PhotoUploader < CarrierWave::Uploader::Base
include ::CarrierWave::Backgrounder::Delay
include CarrierWave::RMagick
storage :fog
def store_dir
"uploads/images/"
end
def filename
"#{secure_token}.#{file.extension}" if original_filename.present?
end
def orient_image
manipulate! do |img|
img.auto_orient
img
end
end
# Create different versions of your uploaded files:
version :thumb_small do
process :resize_to_fill => …Run Code Online (Sandbox Code Playgroud) ruby ruby-on-rails image-uploading ruby-on-rails-3 carrierwave