Closed Undistraction closed 10 years ago
Looks like I was approaching this in the wrong way.
I needed to do the following from my controller:
@media_item = @gallery.media_items.new(media_item_params)
# Ensure we are flagged as processing
@media_item.photo.prepare_enqueueing_for(:image)
@media_item.save
# Add Job
@media_item.photo.enqueue_delayed_processing
respond_with(:admin, @galleryable, @media_item)
I'm using Delayed Paperclip alongside direct uploads to S3. My model is called
Photo
and its attachment isimage
.Images are uploaded to S3 using JavaScript from the Photo form. The file is stored in the location that Paperclip expects the original image to be located, and the file details are saved to hidden fields. When the form is submitted, these attributes are written to the Photo model:
Because writing these attributes alone doesn't seem to be enough to trigger Delayed Paperclip to process the image, after
Photo.save
I callPhoto.image.reprocess!
which does get DelayedPaperclip to create a new Sidekiq job which successfully processes the image.The problem, is that when I call
Photo.save
in thePhotosController
, the file is copied to atemp
directory from S3, then back to S3. This happens outside of the job and is blocking: