jstorimer / delayed_paperclip

Process your Paperclip attachments in the background with delayed_job or Resque.
https://github.com/jrgifford/delayed_paperclip/
392 stars 245 forks source link

Process completion notification #64

Open mhuggins opened 12 years ago

mhuggins commented 12 years ago

This should be tagged as a feature request, but there doesn't appear to be a list of tags when opening an issue for delayed_paperclip.

It would be nice to have a way to know when the image is finished processing. This would allow websites, for example, to render a placeholder loading spinner after an image is submitted, allowing the spinner to be replaced by the true image via AJAX when it is done processing and available for display.

cristianbica commented 12 years ago

You have 2 options here:

  1. You can define an boolena attribute "#{attachment_name}_processing" on your model which will be updated when the post process will finish. See the code https://github.com/jstorimer/delayed_paperclip/blob/master/lib/delayed_paperclip/attachment.rb#L52.
  2. You can use the paperclip's callbacks (before__postprocess and after_post_process). At https://github.com/thoughtbot/paperclip search for events. I used those events a while ago and I remember that I run into some troubles when trying to change the model data with callbacks in the post_process callback
jrgifford commented 12 years ago

@cristianbica is correct on that from what I'm seeing.