Reputation: 16275
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.
Upvotes: 9
Views: 4827
Reputation: 5398
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
Upvotes: 13