Skip to content

Instantly share code, notes, and snippets.

@Olefine
Created August 20, 2013 13:41
Show Gist options
  • Save Olefine/6281588 to your computer and use it in GitHub Desktop.
Save Olefine/6281588 to your computer and use it in GitHub Desktop.
class AmazonImageUploader
def initialize(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) }
@file = path
@id = id
end
def process
@uploader = MessageImageUploader.new
raise "Uploader not created" if @uploader.nil?
@uploader.store!(File.open(@file))
Resque.enqueue(MessageImageWorker, @id, @uploader)
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment