Unfortunately, the award was given to an answer that does not solve this problem, for those who have similar problems.
I have an image upload form (heroku to s3). When I submit the form, my rails server waits for a background job that loads the image until it completes before returning a response to the user. This causes an application timeout every time there is an image download.
Current order of events:
- User Submits Form
- The server receives the form
- If there is an image, the server starts a background job
- If the background task has begun, the server waits for its completion (the time of the rails is here)
- If started, the background job ends
- The server is processing the request.
- The server is responding to the user
Desired order of events:
- User Submits Form
- The server receives the form
- Server processes fields without image
- If there is an image, the server starts a background job
- The server is responding to the user
- The background job runs and the server processes the downloaded image (saves the URL)
Bootloader code
class PhotoUploader < CarrierWave::Uploader::Base include ::CarrierWave::Backgrounder::Delay include CarrierWave::MimeTypes process :set_content_type storage :fog end
Carrierwave :: initializer backgrounder
CarrierWave::Backgrounder.configure do |c| c.backend :sidekiq, queue: :carrierwave end
User model
class User < ActiveRecord::Base mount_uploader :photo, PhotoUploader, delayed: true process_in_background :photo end
The controller code is missing because the form is being processed by ActiveAdmin. I can redefine where necessary, but could not figure out what needs to be changed.
What do I need to change to get the correct order of events?
source share