-
-
Save kirs/6281764 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class MessageImageWorker | |
@queue = :message_image_queue | |
def self.perform(message_id, image_path) | |
MessageImage.create!(message_id: message_id, image: image_path) | |
end | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class AmazonImageUploader | |
def initialize(message_id, file) | |
name = file[0][:image].original_filename | |
directory = "public/uploads/" | |
path = File.join(directory, name) | |
File.open(path, "wb") { |f| f.write(file[0][:image].read) } | |
@path = path | |
@message_id = message_id | |
end | |
def process | |
Resque.enqueue(MessageImageWorker, @message_id, @path) | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment