ruby-on-rails – CarrierWave Backgrounder不会将版本映像上传到AWS S3

我使用带有RMagic的carrierwave 0.10.0 gem来在AWS S3上上传图像.一切都运行正常,除了花费太多时间在AWS S3上传.所以想到使用carrierwave背景来在背景中上传图像.我设置了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

有什么我想念的东西.请帮忙
提前致谢

解决方法

经过少量文件调查后,我的建议如下:

来自careerwave_backgrounder自述文件https://github.com/lardawge/carrierwave_backgrounder#background-options

它清楚地显示,

# This stores the original file with no processing/versioning.
# It will upload the original file to s3.

从这个#113,作者说

I found a bug related to Rmagick but no issue with versions

您可以尝试使用MiniMagick / ImageMagick而不是RMagick.

寻找类似问题的文档:

https://github.com/lardawge/carrierwave_backgrounder/issues/113

https://github.com/lardawge/carrierwave_backgrounder/issues/130

Rails CarrierWave versions are not created for some reason

谢谢!

相关文章

validates:conclusion,:presence=>true,:inclusion=>{...
一、redis集群搭建redis3.0以前,提供了Sentinel工具来监控各...
分享一下我老师大神的人工智能教程。零基础!通俗易懂!风趣...
上一篇博文 ruby传参之引用类型 里边定义了一个方法名 mo...
一编程与编程语言 什么是编程语言? 能够被计算机所识别的表...
Ruby类和对象Ruby是一种完美的面向对象编程语言。面向对象编...