AWS S3 üzerinde resim yüklemek için carrierwave 0.10.0 gem RMagic kullanıyordum. Her şey gayet iyi çalışıyordu, çünkü AWS S3'e yüklemek için çok fazla zaman harcıyordu. Arka planda görüntüleri yüklemek için carrierwave arka planlayıcısı kullanarak düşündüm. Carrierwave arka planlayıcısı (0.4.2) kurdum ama bu orjinal dosyamda her zaman S3'e yükleme yapılıyor ancak bu görüntünün sürümleri asla S3'e yüklenmiyor. İşte CarrierWave Backgrounder, resim görüntülerini AWS S3'e yüklemiyor.
Ben buradaSidekiq.configure_server do |config|
config.redis = { :url => "redis://#{ENV['REDIS_ENDPOINT']}:6379", :namespace=> "#{ENV['REDIS_NAMESPACE']}" }
config.options =
queues: %w{
critical
carrierwave
}
})
end
sidekiq.rb benim kuyruğunu tanımladıktan benim carrierwave_backgrounder.rb
CarrierWave::Backgrounder.configure do |c|
c.backend :sidekiq, queue: :carrierwave
end
benim photo_uploader.rb İşte
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
olan benim profilim .rb dosya
Ben image_url sadece orijinal görüntü yüklenir yüklediğinizde ben bu komutubundle exec sidekiq -d -L log/sidekiq.log -C config/sidekiq.yml -e development
kullanarak sidekiq işçisi başladık
mount_uploader :image_url, PhotoUploader
process_in_background :image_url
. Bu, orijinal dosyayı yükledikten sonra sidekiq günlüğüdür. Ancak, herhangi bir sürüm dosyası göremiyorum. S3 paketini de kontrol ettim (sürüm dosyası sadece orijinal dosya)
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
Eksik olduğum bir şey var mı?
careerwave_backgrounder readme: From: birkaç documentations yaptığımız araştırma sonrasında Advance
Bir hata gibi geliyor, gemide hata ayıklamayı denediniz mi? Böyle garip görünüyordu? https://stackoverflow.com/questions/15490972/carrierwave-processed-images-not-uploading-to-aws-s3?rq=1 – bbozo
@rohit kumar Bu sorunu hala yaşıyor musunuz? Şimdi bununla yüzleşiyorum ve nasıl çözeceğime dair hiçbir fikrim yok. Bütün gün dolaşıyor ama hiçbir şey bulunamadı. –