Created
May 13, 2011 11:11
-
-
Save namxam/970361 to your computer and use it in GitHub Desktop.
typhoeus example
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
require 'rubygems' | |
require 'typhoeus' | |
hydra = Typhoeus::Hydra.new | |
# Create all your requests | |
request = Typhoeus::Request.new("http://your_image_url") | |
request.on_complete do |response| | |
# Check if the returned data really is an image | |
# Save the fetched file / image | |
File.open(file_path, 'w+') do |file| | |
file.write(response.body) | |
end | |
# Do some post processing like resizing | |
end | |
hydra.queue request | |
hydra.run |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment