I want to handle uploading document
doc
's(files) to S3 in the background, but for some reason, it doesn't work for me. I'm currently running this locally.
This is my setup:
class DocUploader < CarrierWave::Uploader::Base
# Include RMagick or MiniMagick support:
include CarrierWave::MiniMagick
include ::CarrierWave::Backgrounder::Delay
# Choose what kind of storage to use for this uploader:
storage :fog
end
# /config/initializers/carrierwave_backgrounder.rb
CarrierWave::Backgrounder.configure do |c|
c.backend :sidekiq, queue: :carrierwave
end
# documents_controller.rb
def document_params
params.require(:document).permit(
..., :doc, :doc_tmp, :remove_doc, ...
)
end
# sidekiq.yml
---
:queues:
- [default,5]
- [carrierwave,5]
I run sidekiq
using the command:
bundle exec sidekiq
when I try to upload doc
for document
with the following setting: (store_in_background)
# doc :string
# doc_processing :boolean default(FALSE), not null
# doc_tmp :string
class Document < ActiveRecord::Base
mount_uploader :doc, DocUploader
store_in_background :doc
# process_in_background :doc
attr_accessor :doc_tmp
end
it doesn't seem to enqueue any jobs in the background in sidekiq and the doc
saving is done in-process and it takes a long time.
Any suggestions?