我使用带有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
我在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
这是我的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 => [100,100] process :strip end def strip manipulate! do |img| img.strip! img = yield(img) if block_given? img end end def extension_white_list %w(jpg jpeg gif png) end def get_version_dimensions model.width, model.height = `identify -format "%wx%h " #{file.path}`.split(/x/) end protected def secure_token var = :"@#{mounted_as}_secure_token" model.instance_variable_get(var) || model.instance_variable_set(var, SecureRandom.hex(5)) end end
这是我的profile.rb文件
mount_uploader :image_url, PhotoUploader process_in_background :image_url
我已经使用此命令启动了sidekiq worker
bundle exec sidekiq -d -L log/sidekiq.log -C config/sidekiq.yml -e development
当我上传image_url时,仅上传原始图像.这是上传原始文件后的sidekiq日志.但我没有看到上传任何版本文件.我也查了S3桶(没有版本文件只有原始文件)
2016-01-11T08:52:20.772Z 3983 TID-ownpyrrxk CarrierWave::Workers::ProcessAsset JID-91e3803d50defb2d1419cef1 INFO: start 2016-01-11T08:52:31.119Z 3983 TID-ownpyrrxk CarrierWave::Workers::ProcessAsset JID-91e3803d50defb2d1419cef1 INFO: done: 10.347 sec
有什么我想念的东西.请提前帮助谢谢