I am using the Paperclip gem to resize upload photos and store them on amazon S3. I need access to the resized photo to also pass along to another web service, during the lifecycle of the upload request.
I suspect there is a temp file created somewhere the imagemagik uses before the photo is uploaded to s3. How can I get access to it.
According to Paperclip readme there're a few callbacks that it calls after and before processing.
For each attachment:
Only for a specific attachment:
I think in your case you should use one of the after
callbacks to get the resized photo. Then you should be able to access the file with queued_for_write
. For example:
class MyModel < ActiveRecord::Base
has_attached_file :photo, :styles => { :small => "300x300>" }
after_post_process :send_photo
private
def send_photo
path = photo.queued_for_write[:small].path
# upload the photo to the ws here
end
end
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With